Skip to content

Commit

Permalink
feat: revamp status command (#114)
Browse files Browse the repository at this point in the history
This PR improves the feedback of the status command to live update the
services responses. One "breaking change" is the removal of the --all/-a
option. With the idea to give better visibility of the overall status,
that option doesn't make that much sense. (we can of course add it back
if we think is very important here).

Changelog:
- Removed --all/-a options. Now all services are shown by default.
- Added dependency to
[`crossterm`](https://docs.rs/crossterm/latest/crossterm/) to manipulate
the terminal output.
- Cleaned up the output (removed "Service information:" and "Session
information:" headers).
- Services statuses are update as soon as we get them.
- Removed `component_kind: linkup`. Internal Linkup services are
reported as remote or local accordingly.
- Added priority option for component status. This way we can keep the
Linkup internal services reported on the beginning of the list.
  • Loading branch information
augustoccesar authored Oct 29, 2024
1 parent 25d2507 commit 9b8614e
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 131 deletions.
50 changes: 49 additions & 1 deletion Cargo.lock

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

3 changes: 2 additions & 1 deletion linkup-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "linkup-cli"
version = "1.1.1"
version = "1.2.0"
edition = "2021"

[[bin]]
Expand Down Expand Up @@ -31,6 +31,7 @@ thiserror = "1.0.64"
url = { version = "2.5.2", features = ["serde"] }
base64 = "0.22.1"
env_logger = "0.11.5"
crossterm = "0.28.1"

[dev-dependencies]
mockall = "0.13.0"
15 changes: 14 additions & 1 deletion linkup-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::{env, fs, io::ErrorKind, path::PathBuf};

use clap::{builder::ValueParser, Parser, Subcommand};
use clap_complete::Shell;
use colored::Colorize;
use thiserror::Error;

mod background_booting;
Expand Down Expand Up @@ -252,7 +253,19 @@ fn main() -> Result<()> {
Commands::Reset => reset(),
Commands::Local { service_names, all } => local(service_names, *all),
Commands::Remote { service_names, all } => remote(service_names, *all),
Commands::Status { json, all } => status(*json, *all),
Commands::Status { json, all } => {
// TODO(augustocesar)[2024-10-28]: Remove --all/-a in a future release.
// Do not print the warning in case of JSON so it doesn't break any usage if the result of the command
// is passed on to somewhere else.
if *all && !*json {
let warning =
"--all/-a is a noop now. All services statuses will always be shown. \
This arg will be removed in a future release.\n";
println!("{}", warning.yellow());
}

status(*json)
}
Commands::LocalDNS { subcommand } => match subcommand {
LocalDNSSubcommand::Install => local_dns::install(&cli.config),
LocalDNSSubcommand::Uninstall => local_dns::uninstall(&cli.config),
Expand Down
2 changes: 1 addition & 1 deletion linkup-cli/src/preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn preview(
.preview(&create_preview_request)
.map_err(|e| CliError::LoadConfig(url.to_string(), e.to_string()))?;

print_session_status(SessionStatus {
print_session_status(&SessionStatus {
name: preview_name.clone(),
domains: format_state_domains(&preview_name, &input_config.domains),
});
Expand Down
Loading

0 comments on commit 9b8614e

Please sign in to comment.