mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
add free arg
This commit is contained in:
parent
a808f0a0f4
commit
f042c39180
2 changed files with 60 additions and 8 deletions
|
@ -3019,8 +3019,23 @@ The declaration file could be saved and used for typing information.",
|
|||
fn upgrade_subcommand() -> Command {
|
||||
command(
|
||||
"upgrade",
|
||||
"Upgrade deno executable to the given version.
|
||||
Defaults to latest.
|
||||
color_print::cstr!("<g>Upgrade</> deno executable to the given version.
|
||||
|
||||
<g>Latest</>
|
||||
|
||||
deno upgrade
|
||||
|
||||
<g>Specific version</>
|
||||
|
||||
deno upgrade <p(245)>1.45.0</>
|
||||
deno upgrade <p(245)>1.46.0-rc.1</>
|
||||
deno upgrade <p(245)>9bc2dd29ad6ba334fd57a20114e367d3c04763d4</>
|
||||
|
||||
<g>Channel</>
|
||||
|
||||
deno upgrade <p(245)>stable</>
|
||||
deno upgrade <p(245)>rc</>
|
||||
deno upgrade <p(245)>canary</>
|
||||
|
||||
The version is downloaded from
|
||||
https://github.com/denoland/deno/releases
|
||||
|
@ -3028,7 +3043,7 @@ and is used to replace the current executable.
|
|||
|
||||
If you want to not replace the current Deno executable but instead download an
|
||||
update to a different location, use the --output flag:
|
||||
deno upgrade --output $HOME/my_deno",
|
||||
deno upgrade --output $HOME/my_deno"),
|
||||
UnstableArgsConfig::None,
|
||||
)
|
||||
.hide(cfg!(not(feature = "upgrade")))
|
||||
|
@ -3038,7 +3053,8 @@ update to a different location, use the --output flag:
|
|||
Arg::new("version")
|
||||
.long("version")
|
||||
.help("The version to upgrade to")
|
||||
.help_heading(UPGRADE_HEADING),
|
||||
.help_heading(UPGRADE_HEADING)// NOTE(bartlomieju): pre-v1.46 compat
|
||||
.hide(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("output")
|
||||
|
@ -3068,7 +3084,8 @@ update to a different location, use the --output flag:
|
|||
.long("canary")
|
||||
.help("Upgrade to canary builds")
|
||||
.action(ArgAction::SetTrue)
|
||||
.help_heading(UPGRADE_HEADING),
|
||||
.help_heading(UPGRADE_HEADING)// NOTE(bartlomieju): pre-v1.46 compat
|
||||
.hide(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("release-candidate")
|
||||
|
@ -3076,11 +3093,13 @@ update to a different location, use the --output flag:
|
|||
.help("Upgrade to a release candidate")
|
||||
.conflicts_with_all(["canary", "version"])
|
||||
.action(ArgAction::SetTrue)
|
||||
.help_heading(UPGRADE_HEADING),
|
||||
.help_heading(UPGRADE_HEADING)
|
||||
// NOTE(bartlomieju): pre-v1.46 compat
|
||||
.hide(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("version-or-hash-or-channel")
|
||||
.help("Version, channel or commit hash")
|
||||
.help(color_print::cstr!("Version <p(245)>(v1.46.0)</>, channel <p(245)>(rc, canary)</> or commit hash <p(245)>(9bc2dd29ad6ba334fd57a20114e367d3c04763d4)</>"))
|
||||
.value_name("VERSION")
|
||||
.action(ArgAction::Append)
|
||||
.trailing_var_arg(true),
|
||||
|
|
|
@ -547,7 +547,7 @@ pub async fn upgrade(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
enum RequestedVersion {
|
||||
Latest(ReleaseChannel),
|
||||
SpecificVersion(ReleaseChannel, String),
|
||||
|
@ -1048,6 +1048,39 @@ mod test {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_requested_version() {
|
||||
let mut upgrade_flags = UpgradeFlags {
|
||||
dry_run: false,
|
||||
force: false,
|
||||
release_candidate: false,
|
||||
canary: false,
|
||||
version: None,
|
||||
output: None,
|
||||
version_or_hash_or_channel: None,
|
||||
};
|
||||
|
||||
let req_ver =
|
||||
RequestedVersion::from_upgrade_flags(upgrade_flags.clone()).unwrap();
|
||||
assert_eq!(req_ver, RequestedVersion::Latest(ReleaseChannel::Stable));
|
||||
|
||||
let req_ver =
|
||||
RequestedVersion::from_upgrade_flags(upgrade_flags.clone()).unwrap();
|
||||
assert_eq!(req_ver, RequestedVersion::Latest(ReleaseChannel::Stable));
|
||||
|
||||
let req_ver =
|
||||
RequestedVersion::from_upgrade_flags(upgrade_flags.clone()).unwrap();
|
||||
assert_eq!(req_ver, RequestedVersion::Latest(ReleaseChannel::Stable));
|
||||
|
||||
let req_ver =
|
||||
RequestedVersion::from_upgrade_flags(upgrade_flags.clone()).unwrap();
|
||||
assert_eq!(req_ver, RequestedVersion::Latest(ReleaseChannel::Stable));
|
||||
|
||||
let req_ver =
|
||||
RequestedVersion::from_upgrade_flags(upgrade_flags.clone()).unwrap();
|
||||
assert_eq!(req_ver, RequestedVersion::Latest(ReleaseChannel::Stable));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_upgrade_check_file() {
|
||||
// NOTE(bartlomieju): pre-1.46 format
|
||||
|
|
Loading…
Reference in a new issue