From 28a7ef3a941de0d641efaa24314ff0c6cf126f4a Mon Sep 17 00:00:00 2001 From: despiegk Date: Wed, 9 Apr 2025 09:47:16 +0200 Subject: [PATCH] ... --- README.md | 10 +++++----- build.sh | 15 +++++++++++++++ doctreecmd/Cargo.toml | 4 ++++ doctreecmd/src/main.rs | 6 +++--- example_commands.sh | 2 +- runexample.sh | 2 +- 6 files changed, 29 insertions(+), 10 deletions(-) create mode 100755 build.sh diff --git a/README.md b/README.md index 4a312b3..cd523ab 100644 --- a/README.md +++ b/README.md @@ -79,12 +79,12 @@ FLAGS: -V, --version Prints version information SUBCOMMANDS: - delete-collection Delete a collection from Redis + delete Delete a collection get Get page content html Get page content as HTML info Show detailed information about collections list List collections - reset Delete all collections from Redis + reset Delete all collections scan Scan a directory for .collection files and create collections ``` @@ -133,10 +133,10 @@ This command shows detailed information about a collection, including its docume #### Deleting a Collection ```bash -doctreecmd delete-collection collection_name --doctree my_doctree +doctreecmd delete collection_name --doctree my_doctree ``` -This command deletes a collection from Redis. +This command deletes a collection. #### Resetting All Collections @@ -144,7 +144,7 @@ This command deletes a collection from Redis. doctreecmd reset --doctree my_doctree ``` -This command deletes all collections from Redis. +This command deletes all collections. ## Implementation Details diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..79fad9f --- /dev/null +++ b/build.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# Change to the directory where the script is located +cd "$(dirname "$0")" +# Exit immediately if a command exits with a non-zero status +set -e + +echo "Building doctree binary..." +cd doctreecmd +cargo build --release + +echo "Copying doctree binary to ~/hero/bin/" +mkdir -p ~/hero/bin/ +cp target/release/doctree ~/hero/bin/ + +echo "Build and installation complete!" \ No newline at end of file diff --git a/doctreecmd/Cargo.toml b/doctreecmd/Cargo.toml index e2bc869..ae89f45 100644 --- a/doctreecmd/Cargo.toml +++ b/doctreecmd/Cargo.toml @@ -3,6 +3,10 @@ name = "doctreecmd" version = "0.1.0" edition = "2024" +[[bin]] +name = "doctree" +path = "src/main.rs" + [dependencies] doctree = { path = "../doctree" } clap = "3.2.25" diff --git a/doctreecmd/src/main.rs b/doctreecmd/src/main.rs index 27f35e3..3bd9723 100644 --- a/doctreecmd/src/main.rs +++ b/doctreecmd/src/main.rs @@ -3,7 +3,7 @@ use doctree::{DocTree, RedisStorage, Result, from_directory}; use std::path::Path; fn main() -> Result<()> { - let matches = App::new("DocTree CLI") + let matches = App::new("doctree") .version("0.1.0") .author("Your Name") .about("A tool to manage document collections") @@ -53,7 +53,7 @@ fn main() -> Result<()> { .arg(Arg::with_name("doctree").long("doctree").takes_value(true).help("Name of the doctree (default: 'default')")), ) .subcommand( - SubCommand::with_name("delete-collection") + SubCommand::with_name("delete") .about("Delete a collection from Redis") .arg(Arg::with_name("collection").required(true).help("Name of the collection")) .arg(Arg::with_name("doctree").long("doctree").takes_value(true).help("Name of the doctree (default: 'default')")), @@ -266,7 +266,7 @@ fn main() -> Result<()> { } } } - } else if let Some(matches) = matches.subcommand_matches("delete-collection") { + } else if let Some(matches) = matches.subcommand_matches("delete") { let collection = matches.value_of("collection").unwrap(); let doctree_name = matches.value_of("doctree").unwrap_or("default"); diff --git a/example_commands.sh b/example_commands.sh index 5001782..d7d8db2 100755 --- a/example_commands.sh +++ b/example_commands.sh @@ -19,7 +19,7 @@ echo -e "\n=== Getting Document (HTML) ===" cargo run -- get -c grid_documentation -p introduction.md -f html echo -e "\n=== Deleting Collection ===" -cargo run -- delete-collection grid_documentation +cargo run -- delete grid_documentation echo -e "\n=== Listing Remaining Collections ===" cargo run -- list diff --git a/runexample.sh b/runexample.sh index 0295553..e8c5530 100755 --- a/runexample.sh +++ b/runexample.sh @@ -24,7 +24,7 @@ cargo run -- get -p 01_features.md --doctree supercollection # Delete a specific collection echo -e "\n=== Deleting Collection ===" -cargo run -- delete-collection grid_documentation --doctree supercollection +cargo run -- delete grid_documentation --doctree supercollection # List remaining collections echo -e "\n=== Listing Remaining Collections ==="