Skip to content

Commit 75f3e9b

Browse files
committed
add enqueue/prepend command to allow for queueing, bump to 3.8.0, bump deps
1 parent 858b938 commit 75f3e9b

7 files changed

Lines changed: 99 additions & 48 deletions

File tree

Cargo.lock

Lines changed: 43 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sigi"
3-
version = "3.7.2"
3+
version = "3.8.0"
44
authors = ["Justin \"Boonie Pepper\" Hill <justin@so.dang.cool>"]
55
edition = "2021"
66
license = "GPL-2.0-only"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Commands:
2929
delete Move the current item to "<STACK>_history" and mark as deleted [aliases: pop, remove, cancel, drop]
3030
delete-all Move all items to "<STACK>_history" and mark as deleted [aliases: purge, pop-all, remove-all, cancel-all, drop-all]
3131
edit Edit the content of an item. Other metadata like creation date is left unchanged
32+
enqueue Create a new item at the bottom/beginning of the stack. Effectively allows queue behavior [aliases: enq, prepend]
3233
head Print the first N items (default is 10) [aliases: top, first]
3334
is-empty Print "true" if stack has zero items, or print "false" (and exit with a nonzero exit code) if the stack does have items [aliases: empty]
3435
list Print all items [aliases: ls, snoop, all]

sigi.1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH sigi 1 "May 16, 2025" "version 3.7.2" "USER COMMANDS"
1+
.TH sigi 1 "June 23, 2026" "version 3.8.0" "USER COMMANDS"
22
.\"
33
.SH NAME
44
sigi \- An organizing tool for terminal lovers who hate organizing
@@ -79,6 +79,9 @@ Move all items to "<STACK>_history" and mark as deleted [aliases: purge, pop-all
7979
edit
8080
Edit the content of an item. Other metadata like creation date is left unchanged
8181
.TP
82+
enqueue
83+
Create a new item at the bottom/beginning of the stack. Effectively allows queue behavior [aliases: enq, prepend]
84+
.TP
8285
head N
8386
Print the first N items [aliases: top, first]
8487
.TP

src/cli.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const DELETE_ALL_TERMS: [&str; 6] = [
3232
"drop-all",
3333
];
3434
const EDIT_TERMS: [&str; 1] = ["edit"];
35+
const ENQUEUE_TERMS: [&str; 3] = ["enqueue", "enq", "prepend"];
3536
const HEAD_TERMS: [&str; 3] = ["head", "top", "first"];
3637
const IS_EMPTY_TERMS: [&str; 2] = ["is-empty", "empty"];
3738
const LIST_TERMS: [&str; 4] = ["list", "ls", "snoop", "all"];
@@ -167,6 +168,16 @@ enum Command {
167168
fc: FormatConfig,
168169
},
169170

171+
/// Create a new item at the bottom/beginning of the stack. Effectively allows queue behavior
172+
#[command(visible_aliases = &ENQUEUE_TERMS[1..])]
173+
Enqueue {
174+
// The content to add as an item. Multiple arguments will be interpreted as a single string
175+
content: Vec<String>,
176+
177+
#[command(flatten)]
178+
fc: FormatConfig,
179+
},
180+
170181
/// Print the first N items (default is 10)
171182
#[command(visible_aliases = &HEAD_TERMS[1..])]
172183
Head {
@@ -307,6 +318,10 @@ impl Command {
307318
},
308319
fc,
309320
),
321+
Command::Enqueue { content, fc } => {
322+
let content = content.join(" ");
323+
(Enqueue { stack, content }, fc)
324+
}
310325
Command::Head { n, fc } => {
311326
let n = n.unwrap_or(DEFAULT_SHORT_LIST_LIMIT);
312327
(Head { n, stack }, fc)

src/cli/interact.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ fn parse_effect(tokens: Vec<&str>, stack: String) -> ParseEffectResult {
226226
index,
227227
});
228228
}
229+
if ENQUEUE_TERMS.contains(term) {
230+
// FIXME: This is convenient, but normalizes whitespace. Same semantics used in Push. (E.g. multiple spaces always collapsed, tabs to spaces, etc)
231+
let content = tokens[1..].join(" ");
232+
return Effect(Enqueue { stack, content });
233+
}
229234
if HEAD_TERMS.contains(term) {
230235
let n = parse_n().unwrap_or(DEFAULT_SHORT_LIST_LIMIT);
231236
return Effect(Head { stack, n });
@@ -279,7 +284,7 @@ fn parse_effect(tokens: Vec<&str>, stack: String) -> ParseEffectResult {
279284
return Effect(Pick { stack, indices });
280285
}
281286
if PUSH_TERMS.contains(term) {
282-
// FIXME: This is convenient, but normalizes whitespace. (E.g. multiple spaces always collapsed, tabs to spaces, etc)
287+
// FIXME: This is convenient, but normalizes whitespace. Same semantics used in Enqueue. (E.g. multiple spaces always collapsed, tabs to spaces, etc)
283288
let content = tokens[1..].join(" ");
284289
return Effect(Push { stack, content });
285290
}

0 commit comments

Comments
 (0)