-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add upgrade command to auto update fuelup, switch to latest and…
… update installed channels (#625) * feat: add upgrade command to auto update fuelup, switch to latest and update installed channels * test: add upgrade test
- Loading branch information
1 parent
90f9004
commit 27fe0cf
Showing
6 changed files
with
53 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ pub mod fuelup; | |
pub mod show; | ||
pub mod toolchain; | ||
pub mod update; | ||
pub mod upgrade; |
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,16 @@ | ||
use anyhow::Result; | ||
use clap::Parser; | ||
|
||
use crate::ops::fuelup_upgrade; | ||
|
||
#[derive(Debug, Parser)] | ||
pub struct UpgradeCommand { | ||
#[clap(long, short)] | ||
pub force: bool, | ||
} | ||
|
||
pub fn exec(force: bool) -> Result<()> { | ||
fuelup_upgrade::upgrade(force)?; | ||
|
||
Ok(()) | ||
} |
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,13 @@ | ||
use super::{fuelup_default, fuelup_self, fuelup_update}; | ||
use crate::channel::LATEST; | ||
use anyhow::Result; | ||
|
||
pub fn upgrade(force: bool) -> Result<()> { | ||
// self update | ||
fuelup_self::self_update(force)?; | ||
// switch to 'latest' channel. | ||
fuelup_default::default(Some(LATEST.to_owned()))?; | ||
// update channels | ||
fuelup_update::update()?; | ||
Ok(()) | ||
} |
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,15 @@ | ||
use anyhow::Result; | ||
use testcfg::FuelupState; | ||
|
||
pub mod testcfg; | ||
|
||
#[test] | ||
fn fuelup_upgrade() -> Result<()> { | ||
testcfg::setup(FuelupState::LatestToolchainInstalled, &|cfg| { | ||
let output = cfg.fuelup(&["upgrade"]); | ||
let expected_stdout_starts_with = "Already up to date"; | ||
assert!(output.stdout.contains(expected_stdout_starts_with)); | ||
})?; | ||
|
||
Ok(()) | ||
} |