Skip to content

Commit

Permalink
Merge pull request #124 from 56quarters/more-themes
Browse files Browse the repository at this point in the history
Allow mtop theme to be set via CLI flag
  • Loading branch information
56quarters authored Feb 11, 2024
2 parents 4288105 + b8fd2c3 commit afb2c39
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 92 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
screen. #119
- Change default colors in `mtop` to dark theme based on tailwind color
palette. #122
- Allow other `mtop` color palettes to be selected via the `--theme` flag. #124

## v0.8.0 - 2024-02-04

Expand Down
8 changes: 7 additions & 1 deletion mtop/src/bin/mtop.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use clap::{Parser, ValueHint};
use mtop::queue::{BlockingStatsQueue, Host, StatsQueue};
use mtop::ui::{Theme, TAILWIND};
use mtop_client::{
DiscoveryDefault, MemcachedClient, MemcachedPool, MtopError, PoolConfig, SelectorRendezvous, Server, TLSConfig,
Timeout,
Expand All @@ -14,6 +15,7 @@ use tokio::task;
use tracing::instrument::WithSubscriber;
use tracing::{Instrument, Level};

const DEFAULT_THEME: Theme = TAILWIND;
const DEFAULT_LOG_LEVEL: Level = Level::INFO;
// Update interval of more than a second to minimize the chance that stats returned by the
// memcached server have the exact same "time" value (which has one-second granularity).
Expand All @@ -39,6 +41,10 @@ struct MtopConfig {
#[arg(long, default_value=default_log_file().into_os_string(), value_hint = ValueHint::FilePath)]
log_file: PathBuf,

/// Color scheme to use for the UI. Available options are "ansi", "material", and "tailwind".
#[arg(long, default_value_t = DEFAULT_THEME)]
theme: Theme,

/// Enable TLS connections to the Memcached server.
#[arg(long)]
tls_enabled: bool,
Expand Down Expand Up @@ -142,7 +148,7 @@ async fn main() -> ExitCode {

let blocking_measurements = BlockingStatsQueue::new(measurements.clone(), Handle::current());
let hosts: Vec<Host> = servers.iter().map(|s| Host::from(s.id())).collect();
let app = mtop::ui::Application::new(&hosts, blocking_measurements);
let app = mtop::ui::Application::new(&hosts, blocking_measurements, opts.theme);

// Run the terminal reset unconditionally but prefer to return an error from the
// application, if available, for logging.
Expand Down
Loading

0 comments on commit afb2c39

Please sign in to comment.