summaryrefslogtreecommitdiffstats
path: root/src/cli.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-01-14 18:47:54 +0100
committerCanop <cano.petrole@gmail.com>2020-01-14 18:47:54 +0100
commit9756d17d17587bb81985eecbca0335dc6a9715c5 (patch)
tree9560575c4098144588b15a3acf32000b65840a3b /src/cli.rs
parent42186bf348b6598092c07cb34949b6e232c1012f (diff)
`--set-install-state` sets the installation state
This can be used in tests or manual installs to set the installation state. For example, if you make an installation script which automatically installs just the fish function in ~/sea, you may do broot --set-install-state refused --print-shell-function fish > ~/sea/br.fish Fix #148
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 4795fc1..0fc52d0 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -4,6 +4,7 @@
use {
crate::{
errors::{ProgramError, TreeBuildError},
+ shell_install::ShellInstallState,
tree_options::{OptionBool, TreeOptions},
},
std::{
@@ -19,6 +20,7 @@ pub struct AppLaunchArgs {
pub file_export_path: Option<String>, // where to write the produced path (if required with --out)
pub cmd_export_path: Option<String>, // where to write the produced command (if required with --outcmd)
pub print_shell_function: Option<String>, // shell function to print on stdout
+ pub set_install_state: Option<ShellInstallState>, // the state to set
pub tree_options: TreeOptions, // initial tree options
pub commands: Option<String>, // commands passed as cli argument, still unparsed
pub install: bool, // installation is required
@@ -96,11 +98,16 @@ pub fn read_launch_args() -> Result<AppLaunchArgs, ProgramError> {
let print_shell_function = cli_args
.value_of("print-shell-function")
.map(str::to_string);
+ let set_install_state = cli_args
+ .value_of("set-install-state")
+ .map(ShellInstallState::from_str)
+ .transpose()?;
Ok(AppLaunchArgs {
root,
file_export_path,
cmd_export_path,
print_shell_function,
+ set_install_state,
tree_options,
commands,
install,