Skip to content

Commit

Permalink
Bump sigi version to 3.5.0, minor clap 4.0 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
booniepepper committed Nov 11, 2022
1 parent d8db4e9 commit 7684644
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sigi"
version = "3.4.3"
version = "3.5.0"
authors = ["J.R. Hill <hiljusti@so.dang.cool>"]
edition = "2021"
license = "GPL-2.0-only"
Expand Down
2 changes: 1 addition & 1 deletion sigi.1
@@ -1,4 +1,4 @@
.TH sigi 1 "September 21, 2022" "version 3.4.3" "USER COMMANDS"
.TH sigi 1 "November 11, 2022" "version 3.5.0" "USER COMMANDS"
.\"
.SH NAME
sigi \- An organizing tool for terminal lovers who hate organizing
Expand Down
97 changes: 48 additions & 49 deletions src/cli.rs
Expand Up @@ -68,177 +68,177 @@ pub fn run() {
}

#[derive(Parser)]
#[clap(name = "sigi", version = SIGI_VERSION, after_help = INTERACT_INSTRUCTIONS, after_long_help = INTERACT_LONG_INSTRUCTIONS)]
#[command(name = "sigi", version = SIGI_VERSION, after_help = INTERACT_INSTRUCTIONS, after_long_help = INTERACT_LONG_INSTRUCTIONS)]
/// An organizing tool for terminal lovers who hate organizing
struct Cli {
#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,

#[clap(short='t', long, visible_aliases = &["topic", "about", "namespace"])]
#[arg(short='t', long, visible_aliases = &["topic", "about", "namespace"])]
/// Manage items in a specific stack
stack: Option<String>,

#[clap(subcommand)]
#[command(subcommand)]
mode: Option<Mode>,
}

#[derive(Subcommand)]
enum Mode {
/// Run in an interactive mode
#[clap(visible_alias = "i")]
#[command(visible_alias = "i")]
Interactive {
#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Read input lines from standard input. Same commands as interactive
/// mode, but only prints for printing commands. Intended for use in unix
/// pipes
#[clap(name = "-")]
#[command(name = "-")]
ReadStdin,

#[clap(flatten)]
#[command(flatten)]
Command(Command),
}

#[derive(Subcommand)]
enum Command {
/// Move the current item to "<STACK>_history" and mark as completed
#[clap(visible_aliases = &COMPLETE_TERMS[1..])]
#[command(visible_aliases = &COMPLETE_TERMS[1..])]
Complete {
#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Print the total number of items in the stack
#[clap(visible_aliases = &COUNT_TERMS[1..])]
#[command(visible_aliases = &COUNT_TERMS[1..])]
Count {
#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Move the current item to "<STACK>_history" and mark as deleted
#[clap(visible_aliases = &DELETE_TERMS[1..])]
#[command(visible_aliases = &DELETE_TERMS[1..])]
Delete {
#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Move all items to "<STACK>_history" and mark as deleted
#[clap(visible_aliases = &DELETE_ALL_TERMS[1..])]
#[command(visible_aliases = &DELETE_ALL_TERMS[1..])]
DeleteAll {
#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Print the first N items (default is 10)
#[clap(visible_aliases = &HEAD_TERMS[1..])]
#[command(visible_aliases = &HEAD_TERMS[1..])]
Head {
/// The number of items to display
n: Option<usize>,

#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Print "true" if stack has zero items, or print "false" (and exit with a
/// nonzero exit code) if the stack does have items
#[clap(visible_aliases = &IS_EMPTY_TERMS[1..])]
#[command(visible_aliases = &IS_EMPTY_TERMS[1..])]
IsEmpty {
#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Print all items
#[clap(visible_aliases = &LIST_TERMS[1..])]
#[command(visible_aliases = &LIST_TERMS[1..])]
List {
#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Print all stacks
#[clap(visible_aliases = &LIST_STACKS_TERMS[1..])]
#[command(visible_aliases = &LIST_STACKS_TERMS[1..])]
ListStacks {
#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Move current item to another stack
#[clap(arg_required_else_help = true, visible_aliases = &MOVE_TERMS[1..])]
#[command(arg_required_else_help = true, visible_aliases = &MOVE_TERMS[1..])]
Move {
#[clap(name = "destination")]
#[arg(name = "destination")]
/// The stack that will get the source stack's current item
dest: String,

#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Move all items to another stack
#[clap(arg_required_else_help = true, visible_aliases = &MOVE_ALL_TERMS[1..])]
#[command(arg_required_else_help = true, visible_aliases = &MOVE_ALL_TERMS[1..])]
MoveAll {
#[clap(name = "destination")]
#[arg(name = "destination")]
/// The stack that will get all the source stack's items
dest: String,

#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Cycle to the next item; the current item becomes last
#[clap(visible_aliases = &NEXT_TERMS[1..])]
#[command(visible_aliases = &NEXT_TERMS[1..])]
Next {
#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Print the first item. This is the default CLI behavior when no command is given
#[clap(visible_aliases = &PEEK_TERMS[1..])]
#[command(visible_aliases = &PEEK_TERMS[1..])]
Peek {
#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Move items to the top of stack by their number
#[clap(visible_aliases = &PICK_TERMS[1..])]
#[command(visible_aliases = &PICK_TERMS[1..])]
Pick {
ns: Vec<usize>,

#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Create a new item
#[clap(visible_aliases = &PUSH_TERMS[1..])]
#[command(visible_aliases = &PUSH_TERMS[1..])]
Push {
// The content to add as an item. Multiple arguments will be interpreted as a single string
content: Vec<String>,

#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Rotate the three most-current items
#[clap(visible_aliases = &ROT_TERMS[1..])]
#[command(visible_aliases = &ROT_TERMS[1..])]
Rot {
#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Swap the two most-current items
#[clap(visible_aliases = &SWAP_TERMS[1..])]
#[command(visible_aliases = &SWAP_TERMS[1..])]
Swap {
#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},

/// Print the last N items (default is 10)
#[clap(visible_aliases = &TAIL_TERMS[1..])]
#[command(visible_aliases = &TAIL_TERMS[1..])]
Tail {
/// The number of items to display
n: Option<usize>,

#[clap(flatten)]
#[command(flatten)]
fc: FormatConfig,
},
}
Expand Down Expand Up @@ -279,19 +279,19 @@ impl Command {

#[derive(Args)]
struct FormatConfig {
#[clap(short, long)]
#[arg(short, long)]
/// Omit any leading labels or symbols. Recommended for use in shell scripts
quiet: bool,

#[clap(short, long)]
#[arg(short, long)]
/// Omit any output at all
silent: bool,

#[clap(short, long, visible_alias = "noisy")]
#[arg(short, long, visible_alias = "noisy")]
/// Print more information, like when an item was created
verbose: bool,

#[clap(short, long)]
#[arg(short, long)]
/// Use a programmatic format. Options include [csv, json, json-compact, tsv]. Not compatible with quiet/silent/verbose.
format: Option<ProgrammaticFormat>,
}
Expand Down Expand Up @@ -334,7 +334,6 @@ impl FormatConfig {
}

#[derive(ValueEnum, Clone)]
#[clap()]
enum ProgrammaticFormat {
Csv,
Json,
Expand Down
2 changes: 1 addition & 1 deletion tests/basic_sigi_tests.rs
Expand Up @@ -6,6 +6,6 @@ use run_sigi::sigi;
fn sigi_version() {
let res = sigi("_integ::version", &["--version"]);
res.assert_success();
res.assert_stdout_line_starts_with("sigi 3.4");
res.assert_stdout_line_starts_with("sigi 3.5");
res.assert_stderr_empty();
}
4 changes: 2 additions & 2 deletions tests/interactive_tests.rs
Expand Up @@ -6,7 +6,7 @@ use run_sigi::{piping, sigi};
fn sigi_interactive_preamble() {
let res = sigi("_integ::interactive", &["interactive"]);
res.assert_success();
res.assert_stdout_line_starts_with("sigi 3.4");
res.assert_stdout_line_starts_with("sigi 3.5");
res.assert_stdout_line_starts_with(r#"Type "quit", "q", or "exit" to quit"#);
res.assert_stdout_line_starts_with(
r#"Type "?" for quick help, or "help" for a more verbose help message"#,
Expand All @@ -17,7 +17,7 @@ fn sigi_interactive_preamble() {
#[test]
fn sigi_interactive_basic() {
let res = piping(&["push hello world"]).into_sigi("_integ::interactive", &["interactive"]);
res.assert_stdout_line_starts_with("sigi 3.4");
res.assert_stdout_line_starts_with("sigi 3.5");
res.assert_stdout_line_starts_with(r#"Type "quit", "q", or "exit" to quit"#);
res.assert_stdout_line_starts_with(
r#"Type "?" for quick help, or "help" for a more verbose help message"#,
Expand Down
2 changes: 1 addition & 1 deletion tests/run_sigi.rs
Expand Up @@ -259,6 +259,6 @@ fn assert_stderr_empty() {
fn sigi_piping_basic() {
let res = piping(&[]).into_sigi("_integ::basic", &["interactive"]);
assert_eq!(res.status, SigiStatus::Unknown);
res.assert_stdout_line_starts_with("sigi 3.4");
res.assert_stdout_line_starts_with("sigi 3.5");
res.assert_stderr_empty();
}

0 comments on commit 7684644

Please sign in to comment.