mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-08-07 01:33:52 +00:00
cli: polish clap help text across commands
This commit is contained in:
parent
6757fea2bb
commit
eabd4f4ad7
4 changed files with 30 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ use crate::cache::Cache;
|
||||||
use crate::error::IdxError;
|
use crate::error::IdxError;
|
||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
|
#[command(about = "Manage local cache")]
|
||||||
pub struct CacheCmd {
|
pub struct CacheCmd {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub command: CacheSubcommand,
|
pub command: CacheSubcommand,
|
||||||
|
|
@ -11,7 +12,9 @@ pub struct CacheCmd {
|
||||||
|
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
pub enum CacheSubcommand {
|
pub enum CacheSubcommand {
|
||||||
|
#[command(about = "Show cache usage information")]
|
||||||
Info,
|
Info,
|
||||||
|
#[command(about = "Clear all cached files")]
|
||||||
Clear,
|
Clear,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ use crate::config::{config_path, ensure_default_config, get_config_value, set_co
|
||||||
use crate::error::IdxError;
|
use crate::error::IdxError;
|
||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
|
#[command(about = "Manage configuration")]
|
||||||
pub struct ConfigCmd {
|
pub struct ConfigCmd {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub command: ConfigSubcommand,
|
pub command: ConfigSubcommand,
|
||||||
|
|
@ -11,9 +12,13 @@ pub struct ConfigCmd {
|
||||||
|
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
pub enum ConfigSubcommand {
|
pub enum ConfigSubcommand {
|
||||||
|
#[command(about = "Create default configuration file")]
|
||||||
Init,
|
Init,
|
||||||
|
#[command(about = "Get a configuration value by key")]
|
||||||
Get { key: String },
|
Get { key: String },
|
||||||
|
#[command(about = "Set a configuration value by key")]
|
||||||
Set { key: String, value: String },
|
Set { key: String, value: String },
|
||||||
|
#[command(about = "Print configuration file path")]
|
||||||
Path,
|
Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,12 @@ pub enum Shell {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
#[command(name = "idx", about = "Indonesian stock analysis CLI")]
|
#[command(
|
||||||
|
name = "idx",
|
||||||
|
bin_name = "idx",
|
||||||
|
about = "CLI tool for Indonesian stock market (IDX) analysis",
|
||||||
|
long_about = "idx-cli is a Rust command-line tool for Indonesian stock market (IDX) analysis.\nIt supports quote lookup, historical data, local caching, and output formats for both humans and AI agents."
|
||||||
|
)]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
#[arg(short, long, value_enum, global = true)]
|
#[arg(short, long, value_enum, global = true)]
|
||||||
pub output: Option<OutputFormat>,
|
pub output: Option<OutputFormat>,
|
||||||
|
|
@ -34,9 +39,14 @@ pub struct Cli {
|
||||||
|
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
pub enum Commands {
|
pub enum Commands {
|
||||||
|
#[command(about = "Stock data and analysis")]
|
||||||
Stocks(stocks::StocksCmd),
|
Stocks(stocks::StocksCmd),
|
||||||
|
#[command(about = "Manage configuration")]
|
||||||
Config(config::ConfigCmd),
|
Config(config::ConfigCmd),
|
||||||
|
#[command(about = "Manage local cache")]
|
||||||
Cache(cache::CacheCmd),
|
Cache(cache::CacheCmd),
|
||||||
|
#[command(about = "Generate shell completions")]
|
||||||
Completions { shell: Shell },
|
Completions { shell: Shell },
|
||||||
|
#[command(about = "Show idx-cli version")]
|
||||||
Version,
|
Version,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use crate::error::IdxError;
|
||||||
use crate::output::{render_history, render_quotes};
|
use crate::output::{render_history, render_quotes};
|
||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
|
#[command(about = "Stock data and analysis")]
|
||||||
pub struct StocksCmd {
|
pub struct StocksCmd {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub command: StocksSubcommand,
|
pub command: StocksSubcommand,
|
||||||
|
|
@ -15,10 +16,20 @@ pub struct StocksCmd {
|
||||||
|
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
pub enum StocksSubcommand {
|
pub enum StocksSubcommand {
|
||||||
|
#[command(
|
||||||
|
about = "Get real-time stock quotes",
|
||||||
|
after_help = "Examples:\n idx stocks quote BBCA\n idx stocks quote BBCA,BBRI,BMRI\n idx -o json stocks quote BBCA"
|
||||||
|
)]
|
||||||
Quote {
|
Quote {
|
||||||
|
/// One or more symbols, comma-separated or space-separated.
|
||||||
symbols: Vec<String>,
|
symbols: Vec<String>,
|
||||||
},
|
},
|
||||||
|
#[command(
|
||||||
|
about = "Get historical OHLC data",
|
||||||
|
after_help = "Examples:\n idx stocks history BBCA --period 3mo\n idx stocks history BBCA --period 1y --interval 1wk"
|
||||||
|
)]
|
||||||
History {
|
History {
|
||||||
|
/// Single ticker symbol (e.g. BBCA).
|
||||||
symbol: String,
|
symbol: String,
|
||||||
#[arg(long, value_enum, default_value_t = Period::ThreeMonths)]
|
#[arg(long, value_enum, default_value_t = Period::ThreeMonths)]
|
||||||
period: Period,
|
period: Period,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue