pub struct Cli {
pub command: Commands,
pub root: Option<PathBuf>,
pub log_level: LogLevel,
pub format: OutputFormatArg,
pub no_color: bool,
pub config: Option<PathBuf>,
pub quiet: bool,
pub verbose: bool,
}Expand description
Workspace Tools - Changeset-based version management.
This CLI provides comprehensive tools for managing Node.js workspaces using a changeset-based workflow. It supports both single-package and monorepo projects with independent or unified versioning strategies.
§Global Options
All global options apply to ALL subcommands and control behavior across the entire application:
--root: Changes working directory before executing commands--log-level: Controls logging verbosity (stderr only)--format: Controls output format (stdout only)--no-color: Disables ANSI colors in output and logs--config: Override default config file location
§Stream Separation
The CLI maintains strict separation between:
- stderr: Logs only (controlled by
--log-level) - stdout: Command output only (controlled by
--format)
This ensures JSON output is never contaminated with logs, enabling reliable piping and parsing in scripts.
§Examples
# Initialize a new project
workspace init
# Add a changeset
workspace changeset add
# Preview version bump
workspace bump --dry-run
# JSON output with no logs (clean JSON for automation)
workspace --format json --log-level silent bump --dry-run
# Debug logging with text output
workspace --log-level debug changeset listFields§
§command: CommandsSubcommand to execute.
root: Option<PathBuf>Project root directory.
Changes working directory before executing the command. All file operations will be relative to this path.
Default: Current directory
log_level: LogLevelLogging level.
Controls verbosity of operation logs written to stderr. Does NOT affect command output (stdout).
Levels:
- silent: No logs at all
- error: Only critical errors
- warn: Errors + warnings
- info: General progress (default)
- debug: Detailed operations
- trace: Very verbose debugging
Default: info
format: OutputFormatArgOutput format.
Controls format of command output written to stdout. Does NOT affect logging (stderr).
Formats:
- human: Human-readable with colors and tables (default)
- json: Pretty-printed JSON
- json-compact: Compact JSON (single line)
- quiet: Minimal output
Default: human
no_color: boolDisable colored output.
Removes ANSI color codes from both logs (stderr) and output (stdout). Also respects the NO_COLOR environment variable.
Useful for CI/CD environments and file redirection.
config: Option<PathBuf>Path to config file.
Override default config file location. Path can be relative or absolute.
Default: Auto-detect (.changesets.{toml,json,yaml,yml})
quiet: boolQuiet mode.
Minimizes both logs (stderr) and output (stdout).
Equivalent to --log-level silent --format quiet.
Useful for scripts and automation where only exit code matters. Cannot be combined with –log-level, –format, or –verbose.
verbose: boolVerbose output mode.
Increases detail level in command output (stdout) and enables debug logs (stderr).
Equivalent to --log-level debug.
Different from –log-level which only controls operational logs. Cannot be combined with –log-level or –quiet.
Implementations§
Source§impl Cli
impl Cli
Sourcepub const fn log_level(&self) -> LogLevel
pub const fn log_level(&self) -> LogLevel
Returns the raw log level from command line.
Note: Prefer effective_log_level() which accounts for –quiet and –verbose flags.
§Examples
use clap::Parser;
use sublime_cli_tools::cli::{Cli, LogLevel};
let cli = Cli::parse_from(["workspace", "--log-level", "debug", "version"]);
assert_eq!(cli.log_level(), LogLevel::Debug);Sourcepub const fn effective_log_level(&self) -> LogLevel
pub const fn effective_log_level(&self) -> LogLevel
Returns the effective log level, accounting for –quiet and –verbose flags.
Priority:
- –quiet: Returns
Silent - –verbose: Returns
Debug - Otherwise: Returns the value from –log-level
§Examples
use clap::Parser;
use sublime_cli_tools::cli::{Cli, LogLevel};
// --quiet overrides to silent
let cli = Cli::parse_from(["workspace", "--quiet", "version"]);
assert_eq!(cli.effective_log_level(), LogLevel::Silent);
// --verbose sets debug level
let cli = Cli::parse_from(["workspace", "--verbose", "version"]);
assert_eq!(cli.effective_log_level(), LogLevel::Debug);
// Default uses --log-level value
let cli = Cli::parse_from(["workspace", "--log-level", "warn", "version"]);
assert_eq!(cli.effective_log_level(), LogLevel::Warn);Sourcepub const fn output_format(&self) -> OutputFormat
pub const fn output_format(&self) -> OutputFormat
Returns the raw output format from command line.
Note: Prefer effective_output_format() which accounts for –quiet flag.
§Examples
use clap::Parser;
use sublime_cli_tools::cli::Cli;
use sublime_cli_tools::output::OutputFormat;
let cli = Cli::parse_from(["workspace", "--format", "json", "version"]);
assert_eq!(cli.output_format(), OutputFormat::Json);Sourcepub const fn effective_output_format(&self) -> OutputFormat
pub const fn effective_output_format(&self) -> OutputFormat
Returns the effective output format, accounting for –quiet flag.
Priority:
- –quiet: Returns
Quiet - Otherwise: Returns the value from –format
§Examples
use clap::Parser;
use sublime_cli_tools::cli::Cli;
use sublime_cli_tools::output::OutputFormat;
// --quiet overrides to quiet format
let cli = Cli::parse_from(["workspace", "--quiet", "version"]);
assert_eq!(cli.effective_output_format(), OutputFormat::Quiet);
// Default uses --format value
let cli = Cli::parse_from(["workspace", "--format", "json", "version"]);
assert_eq!(cli.effective_output_format(), OutputFormat::Json);Sourcepub fn is_color_disabled(&self) -> bool
pub fn is_color_disabled(&self) -> bool
Returns whether color output is disabled.
Also checks the NO_COLOR environment variable.
§Examples
use clap::Parser;
use sublime_cli_tools::cli::Cli;
let cli = Cli::parse_from(["workspace", "--no-color", "version"]);
assert!(cli.is_color_disabled());Sourcepub const fn root(&self) -> Option<&PathBuf>
pub const fn root(&self) -> Option<&PathBuf>
Returns the root directory.
§Examples
use clap::Parser;
use sublime_cli_tools::cli::Cli;
use std::path::PathBuf;
let cli = Cli::parse_from(["workspace", "--root", "/tmp", "version"]);
assert_eq!(cli.root(), Some(&PathBuf::from("/tmp")));Sourcepub const fn config_path(&self) -> Option<&PathBuf>
pub const fn config_path(&self) -> Option<&PathBuf>
Returns the config file path.
§Examples
use clap::Parser;
use sublime_cli_tools::cli::Cli;
use std::path::PathBuf;
let cli = Cli::parse_from(["workspace", "--config", "custom.toml", "version"]);
assert_eq!(cli.config_path(), Some(&PathBuf::from("custom.toml")));Trait Implementations§
Source§impl Args for Cli
impl Args for Cli
Source§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
Source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
Command so it can instantiate self via
FromArgMatches::update_from_arg_matches_mut Read moreSource§impl CommandFactory for Cli
impl CommandFactory for Cli
Source§impl FromArgMatches for Cli
impl FromArgMatches for Cli
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
ArgMatches to self.