summaryrefslogtreecommitdiff
path: root/cli/args/flags.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/args/flags.rs')
-rw-r--r--cli/args/flags.rs71
1 files changed, 64 insertions, 7 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index 283ebc9a3..1bd30bd68 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -181,6 +181,7 @@ pub struct InstallFlags {
pub name: Option<String>,
pub root: Option<String>,
pub force: bool,
+ pub global: bool,
}
#[derive(Clone, Debug, Eq, PartialEq)]
@@ -194,6 +195,7 @@ pub struct JupyterFlags {
pub struct UninstallFlags {
pub name: String,
pub root: Option<String>,
+ pub global: bool,
}
#[derive(Clone, Debug, Eq, PartialEq)]
@@ -1852,12 +1854,12 @@ fn install_subcommand() -> Command {
.long_about(
"Installs a script as an executable in the installation root's bin directory.
- deno install --allow-net --allow-read https://deno.land/std/http/file_server.ts
- deno install https://examples.deno.land/color-logging.ts
+ deno install --global --allow-net --allow-read https://deno.land/std/http/file_server.ts
+ deno install -g https://examples.deno.land/color-logging.ts
To change the executable name, use -n/--name:
- deno install --allow-net --allow-read -n serve https://deno.land/std/http/file_server.ts
+ deno install -g --allow-net --allow-read -n serve https://deno.land/std/http/file_server.ts
The executable name is inferred by default:
- Attempt to take the file stem of the URL path. The above example would
@@ -1869,7 +1871,7 @@ The executable name is inferred by default:
To change the installation root, use --root:
- deno install --allow-net --allow-read --root /usr/local https://deno.land/std/http/file_server.ts
+ deno install -g --allow-net --allow-read --root /usr/local https://deno.land/std/http/file_server.ts
The installation root is determined, in order of precedence:
- --root option
@@ -1897,6 +1899,13 @@ These must be added to the path manually if required.")
.help("Forcefully overwrite existing installation")
.action(ArgAction::SetTrue))
)
+ .arg(
+ Arg::new("global")
+ .long("global")
+ .short('g')
+ .help("Install a package or script as a globally available executable")
+ .action(ArgAction::SetTrue)
+ )
.arg(env_file_arg())
}
@@ -1948,7 +1957,15 @@ The installation root is determined, in order of precedence:
Arg::new("root")
.long("root")
.help("Installation root")
- .value_hint(ValueHint::DirPath))
+ .value_hint(ValueHint::DirPath)
+ )
+ .arg(
+ Arg::new("global")
+ .long("global")
+ .short('g')
+ .help("Remove globally installed package or module")
+ .action(ArgAction::SetTrue)
+ )
)
}
@@ -3582,6 +3599,7 @@ fn install_parse(flags: &mut Flags, matches: &mut ArgMatches) {
let root = matches.remove_one::<String>("root");
let force = matches.get_flag("force");
+ let global = matches.get_flag("global");
let name = matches.remove_one::<String>("name");
let mut cmd_values = matches.remove_many::<String>("cmd").unwrap();
@@ -3594,6 +3612,7 @@ fn install_parse(flags: &mut Flags, matches: &mut ArgMatches) {
args,
root,
force,
+ global,
});
}
@@ -3611,9 +3630,10 @@ fn jupyter_parse(flags: &mut Flags, matches: &mut ArgMatches) {
fn uninstall_parse(flags: &mut Flags, matches: &mut ArgMatches) {
let root = matches.remove_one::<String>("root");
-
+ let global = matches.get_flag("global");
let name = matches.remove_one::<String>("name").unwrap();
- flags.subcommand = DenoSubcommand::Uninstall(UninstallFlags { name, root });
+ flags.subcommand =
+ DenoSubcommand::Uninstall(UninstallFlags { name, root, global });
}
fn lsp_parse(flags: &mut Flags, _matches: &mut ArgMatches) {
@@ -6525,6 +6545,28 @@ mod tests {
args: vec![],
root: None,
force: false,
+ global: false,
+ }),
+ ..Flags::default()
+ }
+ );
+
+ let r = flags_from_vec(svec![
+ "deno",
+ "install",
+ "-g",
+ "https://deno.land/std/http/file_server.ts"
+ ]);
+ assert_eq!(
+ r.unwrap(),
+ Flags {
+ subcommand: DenoSubcommand::Install(InstallFlags {
+ name: None,
+ module_url: "https://deno.land/std/http/file_server.ts".to_string(),
+ args: vec![],
+ root: None,
+ force: false,
+ global: true,
}),
..Flags::default()
}
@@ -6544,6 +6586,7 @@ mod tests {
args: svec!["foo", "bar"],
root: Some("/foo".to_string()),
force: true,
+ global: false,
}),
import_map_path: Some("import_map.json".to_string()),
no_remote: true,
@@ -6575,6 +6618,20 @@ mod tests {
subcommand: DenoSubcommand::Uninstall(UninstallFlags {
name: "file_server".to_string(),
root: None,
+ global: false,
+ }),
+ ..Flags::default()
+ }
+ );
+
+ let r = flags_from_vec(svec!["deno", "uninstall", "-g", "file_server"]);
+ assert_eq!(
+ r.unwrap(),
+ Flags {
+ subcommand: DenoSubcommand::Uninstall(UninstallFlags {
+ name: "file_server".to_string(),
+ root: None,
+ global: true,
}),
..Flags::default()
}