Skip to content

Commit

Permalink
refactor: using new ContextConfiguration::current() function
Browse files Browse the repository at this point in the history
  • Loading branch information
wangeguo committed Jan 3, 2024
1 parent 930d803 commit 4a18a28
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "amp"
description = "Amphitheatre's official command line tool"
version = "0.5.2"
version = "0.5.3"
edition = "2021"
license = "Apache-2.0"
homepage = "https://amphitheatre.app"
Expand All @@ -11,8 +11,10 @@ readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
amp-client = { git = "https://github.com/amphitheatre-app/amp-client-rust", tag = "v0.6.0" }
amp-common = { git = "https://github.com/amphitheatre-app/common", tag = "v0.6.0" }

amp-client = { git = "https://github.com/amphitheatre-app/amp-client-rust", tag = "v0.6.2" }
amp-common = { git = "https://github.com/amphitheatre-app/common", tag = "v0.6.1" }

anyhow = "1.0.78"
clap = { version = "4.4.12", features = ["derive", "env"] }
clap-verbosity-flag = "2.1.1"
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/context/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ impl Cli {
for (name, cluster) in context.iter() {
let mut row = ContextTable::from(cluster);
row.name = name.clone();
if let Some(current) = context.current() {
row.default = current.title == cluster.title;
if let Some((current, _)) = &context.current() {
row.default = name.eq(current);
}
table.push(row);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/context/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Cli {
let configuration = ctx.configuration.read().await;
let context = configuration.context.as_ref().ok_or(Errors::NotFoundContexts)?;

if let Some(current) = context.current() {
if let Some((_, current)) = context.current() {
println!("{:#?}", current);
} else {
println!("No current context");
Expand Down
2 changes: 1 addition & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl Context {
/// Get the current context from the configuration
fn get_context(configuration: &Configuration) -> Result<Cluster> {
if let Some(context) = &configuration.context {
if let Some(current) = context.current() {
if let Some((_, current)) = context.current() {
return Ok(current.to_owned());
}
}
Expand Down

0 comments on commit 4a18a28

Please sign in to comment.