Skip to content

Commit

Permalink
Migrating back clap from v4 to v3 and removing clap_mangen.
Browse files Browse the repository at this point in the history
clap v4 and clap_mangen are not wrapped for Debian just yet and I have
materialized man pages into the source code as a good start.
Automatically generated man pages required post-editing anyway,
clap_mangen is far from being ready.
  • Loading branch information
igor-petruk committed Jan 8, 2023
1 parent 0d6125f commit 1a54ef2
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 172 deletions.
140 changes: 30 additions & 110 deletions Cargo.lock

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

7 changes: 1 addition & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ scrawl="1.1.0"
users="0.11"
walkdir="2"
number_prefix="0.4"
clap = { version = "4", features = ["derive"] }

[build-dependencies]
clap_mangen="0.2"
clap = { version = "4", features = ["derive", "string"] }
anyhow = '1'
clap = { version = "3", features = ["derive"] }

[dependencies.env_logger]
default-features = false
Expand Down
38 changes: 0 additions & 38 deletions build.rs

This file was deleted.

36 changes: 18 additions & 18 deletions src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ use std::str::FromStr;
pub enum CacheCommand {
/// Shows information about the cache directory for the script.
Info {
#[arg(help = "A filename of the script file.")]
#[clap(help = "A filename of the script file.")]
file: PathBuf,
},
/// Clean the cache for a particular script. Removes the cache directory. Removes the Docker image/volume if
/// they exist, but does not prune.
#[command(visible_alias = "clear")]
#[clap(visible_alias = "clear")]
Clean {
#[arg(help = "A filename of the script file.")]
#[clap(help = "A filename of the script file.")]
file: PathBuf,
},
/// Shows a particular item from "info" by name.
Get {
#[arg(help = "An item name, e.g. cache_path.")]
#[clap(help = "An item name, e.g. cache_path.")]
name: String,
#[arg(help = "A filename of the script file.")]
#[clap(help = "A filename of the script file.")]
file: PathBuf,
},
}
Expand All @@ -43,29 +43,29 @@ pub enum CacheCommand {
pub enum TemplatesCommand {
/// Imports a template from file.
Import {
#[arg(
#[clap(
help = "A filename of the script file. Extension will be stripped for the template name."
)]
file: PathBuf,
},
/// Opens an editor to modify an existing template, nice for quick edits.
Edit {
#[arg(help = "A name of the template to edit")]
#[clap(help = "A name of the template to edit")]
template_name: String,
},
/// Remove a custom template or reset it to the built-in contents.
#[command(name = "rm", visible_aliases = &["remove", "delete"])]
#[clap(name = "rm", visible_aliases = &["remove", "delete"])]
Remove {
#[arg(help = "A name of the template to remove")]
#[clap(help = "A name of the template to remove")]
template_name: String,
},
/// List all templates.
#[command(name = "ls", visible_alias = "list")]
#[clap(name = "ls", visible_alias = "list")]
List {},
}

#[derive(Debug, PartialEq, Eq, Parser, Clone)]
#[command(rename_all = "snake-case")]
#[clap(rename_all = "snake-case")]
pub enum BuildMode {
Default,
Source,
Expand Down Expand Up @@ -97,17 +97,17 @@ impl FromStr for BuildMode {
}

#[derive(Debug, Parser, PartialEq, Eq)]
#[command(
#[clap(
name = "scriptisto",
about = "A 'shebang-interpreter' for compiled languages",
args_conflicts_with_subcommands = true
)]
pub struct Opt {
/// A path for to a script to run and additional arguments passed to this script. A script path must start with '.' or '/'.
#[arg(value_name = "SCRIPT")]
#[clap(value_name = "SCRIPT")]
pub command: Vec<String>,

#[command(subcommand)]
#[clap(subcommand)]
pub cmd: Option<Command>,
}

Expand All @@ -121,23 +121,23 @@ pub enum Command {
/// Prints an example starting script in a programming language of your
/// choice.
New {
#[arg(
#[clap(
help = "If specified, determines a language. Example usage: \"scriptisto new <template_name> | tee new-script\".\nIf not specified, \"new\" lists available templates."
)]
template_name: Option<String>,
},
/// Manage custom script templates.
Template {
#[command(subcommand)]
#[clap(subcommand)]
cmd: TemplatesCommand,
},
/// Build a script without running.
Build {
/// A path to a script to build.
#[arg()]
#[clap()]
script_src: String,
/// Build mode. If unset, only builds if necessary. "source" - to rebuild each time. "full" to fully re-fetch Docker image and run `build_once_cmd`.
#[arg(short, long)]
#[clap(short, long)]
build_mode: Option<BuildMode>,
},
}
Expand Down

0 comments on commit 1a54ef2

Please sign in to comment.