on master help sign in
Add command line parameter to specify log file (#3807)
130793dTobias Hunger
contrib/completion/hx.bash+1−1
@@ -16,7 +16,7 @@ _hx() {
16 COMPREPLY=($(compgen -W "$languages" -- $2))
16 COMPREPLY=($(compgen -W "$languages" -- $2))
17 ;;
17 ;;
18 *)
18 *)
19− COMPREPLY=($(compgen -fd -W "-h --help --tutor -V --version -v -vv -vvv --health -g --grammar --vsplit --hsplit -c --config" -- $2))
19+ COMPREPLY=($(compgen -fd -W "-h --help --tutor -V --version -v -vv -vvv --health -g --grammar --vsplit --hsplit -c --config --log" -- $2))
20 ;;
20 ;;
21 esac
21 esac
22} && complete -F _hx hx
22} && complete -F _hx hx
contrib/completion/hx.elv+7−1
@@ -36,6 +36,11 @@ set edit:completion:arg-completer[hx] = {|@args|
36 edit:complete-filename $args[-1] | each { |v| put $v[stem] }
36 edit:complete-filename $args[-1] | each { |v| put $v[stem] }
37 return
37 return
38 }
38 }
39+ # When we have --log, we need a file
40+ if (has-values "log" $args[-2]) {
41+ edit:complete-filename $args[-1] | each { |v| put $v[stem] }
42+ return
43+ }
39 }
44 }
40 edit:complete-filename $args[-1] | each { |v| put $v[stem]}
45 edit:complete-filename $args[-1] | each { |v| put $v[stem]}
41 $candidate "--help" "(Prints help information)"
46 $candidate "--help" "(Prints help information)"
@@ -46,4 +51,5 @@ set edit:completion:arg-completer[hx] = {|@args|
46 $candidate "--vsplit" "(Splits all given files vertically)"
51 $candidate "--vsplit" "(Splits all given files vertically)"
47 $candidate "--hsplit" "(Splits all given files horizontally)"
52 $candidate "--hsplit" "(Splits all given files horizontally)"
48 $candidate "--config" "(Specifies a file to use for configuration)"
53 $candidate "--config" "(Specifies a file to use for configuration)"
54+ $candidate "--log" "(Specifies a file to write log data into)"
49−}
55+}
contrib/completion/hx.fish+1
@@ -12,3 +12,4 @@ complete -c hx -s V -l version -d "Prints version information"
12complete -c hx -l vsplit -d "Splits all given files vertically into different windows"
12complete -c hx -l vsplit -d "Splits all given files vertically into different windows"
13complete -c hx -l hsplit -d "Splits all given files horizontally into different windows"
13complete -c hx -l hsplit -d "Splits all given files horizontally into different windows"
14complete -c hx -s c -l config -d "Specifies a file to use for completion"
14complete -c hx -s c -l config -d "Specifies a file to use for completion"
15+complete -c hx -s c -l log -d "Specifies a file to write log data into"
contrib/completion/hx.zsh+1
@@ -18,6 +18,7 @@ _hx() {
18 "--hsplit[Splits all given files horizontally into different windows]" \
18 "--hsplit[Splits all given files horizontally into different windows]" \
19 "-c[Specifies a file to use for configuration]" \
19 "-c[Specifies a file to use for configuration]" \
20 "--config[Specifies a file to use for configuration]" \
20 "--config[Specifies a file to use for configuration]" \
21+ "--log[Specifies a file to write log data into]" \
21 "*:file:_files"
22 "*:file:_files"
22
23
23 case "$state" in
24 case "$state" in
helix-term/src/args.rs+5
@@ -14,6 +14,7 @@ pub struct Args {
14 pub build_grammars: bool,
14 pub build_grammars: bool,
15 pub split: Option<Layout>,
15 pub split: Option<Layout>,
16 pub verbosity: u64,
16 pub verbosity: u64,
17+ pub log_file: Option<PathBuf>,
17 pub config_file: Option<PathBuf>,
18 pub config_file: Option<PathBuf>,
18 pub files: Vec<(PathBuf, Position)>,
19 pub files: Vec<(PathBuf, Position)>,
19}
20}
@@ -48,6 +49,10 @@ impl Args {
48 Some(path) => args.config_file = Some(path.into()),
49 Some(path) => args.config_file = Some(path.into()),
49 None => anyhow::bail!("--config must specify a path to read"),
50 None => anyhow::bail!("--config must specify a path to read"),
50 },
51 },
52+ "--log" => match argv.next().as_deref() {
53+ Some(path) => args.log_file = Some(path.into()),
54+ None => anyhow::bail!("--log must specify a path to write"),
55+ },
51 arg if arg.starts_with("--") => {
56 arg if arg.starts_with("--") => {
52 anyhow::bail!("unexpected double dash argument: {}", arg)
57 anyhow::bail!("unexpected double dash argument: {}", arg)
53 }
58 }
helix-term/src/main.rs+2
@@ -67,6 +67,7 @@ FLAGS:
67 -g, --grammar {{fetch|build}} Fetches or builds tree-sitter grammars listed in languages.toml
67 -g, --grammar {{fetch|build}} Fetches or builds tree-sitter grammars listed in languages.toml
68 -c, --config <file> Specifies a file to use for configuration
68 -c, --config <file> Specifies a file to use for configuration
69 -v Increases logging verbosity each use for up to 3 times
69 -v Increases logging verbosity each use for up to 3 times
70+ --log Specifies a file to use for logging
70 (default file: {})
71 (default file: {})
71 -V, --version Prints version information
72 -V, --version Prints version information
72 --vsplit Splits all given files vertically into different windows
73 --vsplit Splits all given files vertically into different windows
@@ -114,6 +115,7 @@ FLAGS:
114 return Ok(0);
115 return Ok(0);
115 }
116 }
116
117
118+ let logpath = args.log_file.as_ref().cloned().unwrap_or(logpath);
117 setup_logging(logpath, args.verbosity).context("failed to initialize logging")?;
119 setup_logging(logpath, args.verbosity).context("failed to initialize logging")?;
118
120
119 let config_dir = helix_loader::config_dir();
121 let config_dir = helix_loader::config_dir();