Skip to content

Commit

Permalink
feat: add graph ascii representation (#103)
Browse files Browse the repository at this point in the history
* feat: add graph ascii representation

* feat: add graph ascii representation
corrected test errors, refactored args
  • Loading branch information
Darioazzali authored Oct 19, 2023
1 parent 1330a27 commit 66a5794
Show file tree
Hide file tree
Showing 8 changed files with 614 additions and 40 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ url = "2.4.1"
assert_cmd = "2.0.12"
semver = "1.0.19"
shlex = "1.2.0"
termgraph = "0.4.0"
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ steps.
curl -fsSL https://raw.githubusercontent.com/zifeo/whiz/main/installer.sh | bash

# via cargo
cargo install whiz --locked
cargo install whiz --locked
cargo install --git https://github.com/zifeo/whiz --locked

# create your tasks file, see https://github.com/zifeo/whiz/blob/main/whiz.yaml for an example
Expand Down Expand Up @@ -75,18 +75,24 @@ complete example.
See `whiz --help` for more information.

| Subcommads | Description |
| ------------------- | ------------------------------------------------- |
| upgrade | Upgrade whiz |
| list-jobs | List all the available jobs |
| graph | Print the graphical ascii representation |
| help | Display help message or the help for subcommand |


| Flags | Description |
| ------------------- | ------------------------------------------------- |
| -f, --file \<FILE\> | Specify the config file |
| -h, --help | Print help information |
| --list-jobs | List all the available jobs |
| -r, --run \<JOB\> | Run specific jobs |
| -t, --timestamp | Enable timestamps in logging |
| -v, --verbose | Enable verbose mode |
| -V, --version | Print whiz version |
| -V, --version | Print whiz version |
| --watch | Globally enable/disable fs watching |
| --exit-after | Exit whiz after all tasks are done. Useful for CI |
| --exit-after | Exit whiz after all tasks are done |


### Key bindings
Expand All @@ -111,3 +117,4 @@ See `whiz --help` for more information.
```bash
cargo run --
```

52 changes: 31 additions & 21 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,67 @@ use clap::{Parser, Subcommand};
#[derive(Parser, Debug, Clone)]
pub struct Upgrade {
/// Upgrade to specific version (e.g. 1.0.0)
#[clap(long)]
#[arg(long)]
pub version: Option<String>,

/// Do not ask for version confirmation
#[clap(short, long, default_value_t = false)]
#[arg(short, long, default_value_t = false)]
pub yes: bool,
}

#[derive(Parser, Debug, Clone)]
pub struct Graph {
/// Draw the line using box-drawing character
#[arg(long, short, default_value_t = false)]
pub boxed: bool,
}

/// Set of subcommands.
#[derive(Subcommand, Debug)]
pub enum Command {
/// Upgrade whiz.
Upgrade(Upgrade),
/// PUpgrade whizrint the graphical ascii representation
Graph(Graph),
/// List all the jobs set in the config file
ListJobs,
}

#[derive(Parser, Debug)]
#[clap(name="whiz", about, long_about = None, disable_version_flag = true, disable_help_flag = true)]
#[command(
name = "whiz",
about,
long_about= None,
)]
pub struct Args {
#[clap(long, value_parser)]
#[arg(long)]
pub version: bool,

#[clap(short, long, value_parser)]
pub help: bool,

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

#[clap(short, long, default_value = "whiz.yaml")]
#[arg(short, long, default_value = "whiz.yaml")]
pub file: String,

#[clap(short, long)]
#[arg(short, long)]
pub verbose: bool,

#[arg(short, long)]
/// Enable timestamps in logging
#[clap(short, long)]
pub timestamp: bool,

/// Run specific jobs
#[clap(short, long, value_name = "JOB")]
#[arg(short, long, value_name = "JOB")]
pub run: Vec<String>,

/// List all the jobs set in the config file
#[clap(long)]
pub list_jobs: bool,

// This disables fs watching despite any values given to the `watch` flag.
//
/// Whiz will exit after all tasks have finished executing.
/// This disables fs watching despite any values given to the `watch` flag.
#[clap(long)]
#[arg(long)]
pub exit_after: bool,

/// Globally toggle triggering task reloading from any watched files
#[clap(long, default_value = "true", value_name = "WATCH")]
pub watch: Option<bool>,
// Globally toggle triggering task reloading from any watched files
/// Globally enable/disable fs watching
#[arg(long, default_value_t = true)]
pub watch: bool,
}
Loading

0 comments on commit 66a5794

Please sign in to comment.