Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update in prep for 0.3.0 release #23

Merged
merged 33 commits into from
Jan 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a031183
Bumped version for next dev cycle.
oubiwann Jan 1, 2024
ea0e6a0
Put shell skeleton in place.
oubiwann Jan 1, 2024
2f5164f
Added shell demo from clap project.
oubiwann Jan 1, 2024
afcd151
Added echo command.
oubiwann Jan 1, 2024
477ad3e
Split up shell code in prep for state management.
oubiwann Jan 1, 2024
91c07a6
Updated to use state struct.
oubiwann Jan 1, 2024
7826695
Added prompt-override support and a banner.
oubiwann Jan 1, 2024
304e92a
Added colour to banner.
oubiwann Jan 1, 2024
819c017
Added history command.
oubiwann Jan 1, 2024
f01e612
Added some more state fields that will be needed.
oubiwann Jan 1, 2024
8b382cb
Stubbed out read and query commands.
oubiwann Jan 1, 2024
b78332a
Updated README with shell info and added screenshot.
oubiwann Jan 1, 2024
c23fe30
Added version command.
oubiwann Jan 1, 2024
63c6060
Cleaned up the API for reading files.
oubiwann Jan 2, 2024
d9b3087
Added 'show' and subcomands.
oubiwann Jan 2, 2024
2dde2b7
Adderd support for reading JSON files.
oubiwann Jan 2, 2024
892958d
Added query support to the shell.
oubiwann Jan 2, 2024
6c6b269
Limit the history size.
oubiwann Jan 2, 2024
bc47340
Updated deps.
oubiwann Jan 2, 2024
3c76376
Updated screenshot.
oubiwann Jan 2, 2024
e733106
Banner tweak.
oubiwann Jan 2, 2024
ee65795
Updated wording.
oubiwann Jan 2, 2024
ebc610e
Fixed shell invocation.
oubiwann Jan 2, 2024
7b92e20
Use the new twyg feature.
oubiwann Jan 2, 2024
5b5874f
Moved run code out of shell mod and into own file.
oubiwann Jan 2, 2024
d6ef395
Added suppoer for showing parsed frontmatter.
oubiwann Jan 2, 2024
cd6d73e
Fixed the display of history.
oubiwann Jan 2, 2024
2784971
Added support for really turning off colour.
oubiwann Jan 4, 2024
c5f2172
Updated to use the latest twyg.
oubiwann Jan 4, 2024
94c98f8
Switched to rustyline for readline support.
oubiwann Jan 5, 2024
b59008a
No longer need bespoke reader.
oubiwann Jan 5, 2024
242b645
Fixed up ^C support.
oubiwann Jan 5, 2024
7e4b575
Removed now-unncessary etx ending support.
oubiwann Jan 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added history command.
oubiwann committed Jan 1, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 819c0179dee02a36684db52f175aec6f93f77bf5
13 changes: 13 additions & 0 deletions src/shell/cmd/handler.rs
Original file line number Diff line number Diff line change
@@ -20,6 +20,10 @@ pub fn echo(state: State, matches: &ArgMatches) -> Result<State, String> {
writer::msg(state, &msg)
}

pub fn history(state: State, _matches: &ArgMatches) -> Result<State, String> {
writer::msg(state.clone(), format_list(state.history).as_str())
}

pub fn ping(state: State, _matches: &ArgMatches) -> Result<State, String> {
writer::msg(state, "pong")
}
@@ -28,3 +32,12 @@ pub fn quit(mut state: State, _matches: &ArgMatches) -> Result<State, String> {
state.quit = true;
writer::msg(state, "\nQuitting ...\n")
}

// Private functions

fn format_list(mut list: Vec<String>) -> String {
const PREFIX: &str = " ";
let mut res: Vec<String> = vec![PREFIX.to_string()];
res.append(&mut list);
format!("\n{}{}\n", PREFIX, res.join(PREFIX).trim())
}
7 changes: 7 additions & 0 deletions src/shell/cmd/mod.rs
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ pub fn dispatch(state: State, line: &str) -> Result<State, String> {
match matches.subcommand() {
Some(("banner", matches)) => handler::banner(state.clone(), matches),
Some(("echo", matches)) => handler::echo(state.clone(), matches),
Some(("history", matches)) => handler::history(state.clone(), matches),
Some(("ping", matches)) => handler::ping(state.clone(), matches),
Some(("quit", matches)) => handler::quit(state.clone(), matches),
Some((name, _matches)) => unimplemented!("{name}"),
@@ -55,6 +56,12 @@ fn cmd() -> Command {
.value_parser(value_parser!(String)),
),
)
.subcommand(
Command::new("history")
.alias("hist")
.about("Show all commands entered so far")
.help_template(USAGE_TEMPLATE),
)
.subcommand(
Command::new("ping")
.about("Check for liveliness")