Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools: use a safer way to initialise settings in vpm (#19755)
- Loading branch information
Showing
4 changed files
with
36 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module main | ||
|
||
import os | ||
import os.cmdline | ||
|
||
struct VpmSettings { | ||
mut: | ||
is_help bool | ||
is_once bool | ||
is_verbose bool | ||
server_urls []string | ||
vcs string | ||
vmodules_path string | ||
no_dl_count_increment bool | ||
} | ||
|
||
fn init_settings() VpmSettings { | ||
args := os.args[1..] | ||
opts := cmdline.only_options(args) | ||
cmds := cmdline.only_non_options(args) | ||
return VpmSettings{ | ||
is_help: '-h' in opts || '--help' in opts || 'help' in cmds | ||
is_once: '--once' in opts | ||
is_verbose: '-v' in opts | ||
vcs: if '--hg' in opts { 'hg' } else { 'git' } | ||
server_urls: cmdline.options(args, '--server-urls') | ||
vmodules_path: os.vmodules_dir() | ||
no_dl_count_increment: os.getenv('VPM_NO_INCREMENT') == '1' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters