Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/man/julia.1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Print command-line options (this message)
Print uncommon options not shown by `-h`

.TP
--project[=<dir>/@.]
-P, --project[=<dir>/@.]
Set <dir> as the active project/environment. The default @. option will search
through parent directories until a Project.toml or JuliaProject.toml file is
found.
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/command-line-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ The following is a complete list of command-line switches available when launchi
|`-v`, `--version` |Display version information|
|`-h`, `--help` |Print command-line options (this message)|
|`--help-hidden` |Print uncommon options not shown by `-h`|
|`--project[={<dir>\|@temp\|@.}]` |Set `<dir>` as the active project/environment. Or, create a temporary environment with `@temp`. The default `@.` option will search through parent directories until a `Project.toml` or `JuliaProject.toml` file is found.|
|`-P`, `--project[={<dir>\|@temp\|@.}]` |Set `<dir>` as the active project/environment. Or, create a temporary environment with `@temp`. The default `@.` option will search through parent directories until a `Project.toml` or `JuliaProject.toml` file is found.|
|`-J`, `--sysimage <file>` |Start up with the given system image file|
|`-H`, `--home <dir>` |Set location of `julia` executable|
|`--startup-file={yes*\|no}` |Load `JULIA_DEPOT_PATH/config/startup.jl`; if [`JULIA_DEPOT_PATH`](@ref JULIA_DEPOT_PATH) environment variable is unset, load `~/.julia/config/startup.jl`|
Expand Down
9 changes: 4 additions & 5 deletions src/jloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static const char opts[] =
" --help-hidden Print uncommon options not shown by `-h`\n\n"

// startup options
" --project[={<dir>|@temp|@.|@script[<rel>]}] Set <dir> as the active project/environment.\n"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this option is now quite long, I have indented the help text a little:

 -P, --project[={<dir>|@temp|@.|@script[<rel>]}]  Set <dir> as the active project/environment.
                                               Or, create a temporary environment with `@temp`
                                               The default @. option will search through parent
                                               directories until a Project.toml or JuliaProject.toml
                                               file is found. @script is similar, but searches up
                                               from the programfile or a path relative to
                                               programfile.
 -J, --sysimage <file>                         Start up with the given system image file
 -H, --home <dir>                              Set location of `julia` executable

Is this OK or would you rather realigning like this?

 -P, --project[={<dir>|@temp|@.|@script[<rel>]}]  Set <dir> as the active project/environment.
                                                  Or, create a temporary environment with `@temp`
                                                  The default @. option will search through parent
                                                  directories until a Project.toml or JuliaProject.toml
                                                  file is found. @script is similar, but searches up
                                                  from the programfile or a path relative to
                                                  programfile.
 -J, --sysimage <file>                            Start up with the given system image file
 -H, --home <dir>                                 Set location of `julia` executable

Or putting it all onto the next line like this?

 -P, --project[={<dir>|@temp|@.|@script[<rel>]}]
                                               Set <dir> as the active project/environment.
                                               Or, create a temporary environment with `@temp`
                                               The default @. option will search through parent
                                               directories until a Project.toml or JuliaProject.toml
                                               file is found. @script is similar, but searches up
                                               from the programfile or a path relative to
                                               programfile.
 -J, --sysimage <file>                         Start up with the given system image file
 -H, --home <dir>                              Set location of `julia` executable

" -P, --project[={<dir>|@temp|@.|@script[<rel>]}] Set <dir> as the active project/environment.\n"
" Or, create a temporary environment with `@temp`\n"
" The default @. option will search through parent\n"
" directories until a Project.toml or JuliaProject.toml\n"
Expand Down Expand Up @@ -400,7 +400,6 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
opt_compiled_modules,
opt_pkgimages,
opt_machine_file,
opt_project,
opt_bug_report,
opt_image_codegen,
opt_rr_detach,
Expand All @@ -417,7 +416,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
opt_experimental_features,
opt_compress_sysimage,
};
static const char* const shortopts = "+vhqH:e:E:L:J:C:it:p:O:g:m:";
static const char* const shortopts = "+vhqH:e:E:L:J:C:it:p:O:g:m:P:";
static const struct option longopts[] = {
// exposed command line options
// NOTE: This set of required arguments need to be kept in sync
Expand All @@ -443,7 +442,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
{ "threads", required_argument, 0, 't' },
{ "gcthreads", required_argument, 0, opt_gc_threads },
{ "machine-file", required_argument, 0, opt_machine_file },
{ "project", optional_argument, 0, opt_project },
{ "project", optional_argument, 0, 'P' },
{ "color", required_argument, 0, opt_color },
{ "history-file", required_argument, 0, opt_history_file },
{ "startup-file", required_argument, 0, opt_startup_file },
Expand Down Expand Up @@ -736,7 +735,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
if (!jl_options.machine_file)
jl_error("julia: failed to allocate memory");
break;
case opt_project:
case 'P':
jl_options.project = optarg ? strdup(optarg) : "@.";
break;
case opt_color:
Expand Down
4 changes: 4 additions & 0 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,15 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
if !Sys.iswindows()
let expanded = abspath(expanduser("~/foo/Project.toml"))
@test expanded == readchomp(`$exename --project='~/foo' -e 'println(Base.active_project())'`)
@test expanded == readchomp(`$exename -P '~/foo' -e 'println(Base.active_project())'`)
@test expanded == readchomp(setenv(`$exename -e 'println(Base.active_project())'`, "JULIA_PROJECT" => "~/foo", "HOME" => homedir()))
end
end

# handling of @projectname in --project and JULIA_PROJECT
let expanded = abspath(Base.load_path_expand("@foo"))
@test expanded == readchomp(`$exename --project='@foo' -e 'println(Base.active_project())'`)
@test expanded == readchomp(`$exename -P '@foo' -e 'println(Base.active_project())'`)
@test expanded == readchomp(addenv(`$exename -e 'println(Base.active_project())'`, "JULIA_PROJECT" => "@foo", "HOME" => homedir()))
end

Expand All @@ -305,12 +307,14 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
# Check running julia with --project=@script both within and outside the script directory
@testset "--@script from $name" for (name, dir) in [("project", expanded), ("outside", pwd())]
@test joinpath(expanded, "Project.toml") == readchomp(Cmd(`$exename --project=@script $script`; dir))
@test joinpath(expanded, "Project.toml") == readchomp(Cmd(`$exename -P @script $script`; dir))
@test joinpath(expanded, "SubProject", "Project.toml") == readchomp(Cmd(`$exename --project=@script/../SubProject $script`; dir))
end
end

# handling of `@temp` in --project and JULIA_PROJECT
@test tempdir() == readchomp(`$exename --project=@temp -e 'println(Base.active_project())'`)[1:lastindex(tempdir())]
@test tempdir() == readchomp(`$exename -P @temp -e 'println(Base.active_project())'`)[1:lastindex(tempdir())]
@test tempdir() == readchomp(addenv(`$exename -e 'println(Base.active_project())'`, "JULIA_PROJECT" => "@temp", "HOME" => homedir()))[1:lastindex(tempdir())]

# --quiet, --banner
Expand Down