Skip to content

Commit

Permalink
moved cargho bach to argh
Browse files Browse the repository at this point in the history
  • Loading branch information
mkatychev committed Jul 11, 2021
1 parent 2fb6fbb commit 2cb78eb
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 49 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### `0.7.2`:
* migrated `cargho` back to `argh` since new version was released

#### `0.7.1`:
* migrated `argh` to `cargho` crate

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "darkroom"
version = "0.7.1"
version = "0.7.2"
description = "A contract testing tool built in Rust"
authors = ["Mikhail Katychev <[email protected]>"]
edition = "2018"
Expand All @@ -22,7 +22,7 @@ members = [

[dependencies]
anyhow = "1.0.40"
cargho = "0.1.7"
argh = "0.1.5"
chrono = "0.4.19"
colored = "2.0.0"
colored-diff = "0.2.2"
Expand Down
82 changes: 41 additions & 41 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::params::BaseParams;
use anyhow::{anyhow, Error};
use cargho::FromArgs;
use argh::FromArgs;
use colored_json::{prelude::*, Colour, Styler};
use serde::Serialize;
use std::{convert::TryFrom, fs, path::PathBuf};
Expand Down Expand Up @@ -44,7 +44,7 @@ pub const fn version() -> &'static str {

/// Darkroom: A contract testing tool built in Rust using the filmReel format.
#[derive(FromArgs, PartialEq, Debug)]
#[cargho(
#[argh(
note = "Use `{command_name} man` for details on filmReel, the JSON format.",
example = "Step through the httpbin test in [-i]nteractive mode:
$ {command_name} -i record ./test_data post",
Expand All @@ -55,38 +55,38 @@ pub const fn version() -> &'static str {
)]
pub struct Command {
/// enable verbose output
#[cargho(switch, short = 'v')]
#[argh(switch, short = 'v')]
verbose: bool,

/// fallback address passed to the specified protocol
#[cargho(positional)]
#[argh(positional)]
address: Option<String>,

/// fallback header passed to the specified protocol
#[cargho(option, short = 'H')]
#[argh(option, short = 'H')]
header: Option<String>,

/// output of final cut file
#[cargho(option, arg_name = "file")]
#[argh(option, arg_name = "file")]
cut_out: Option<PathBuf>,

/// interactive frame sequence transitions
#[cargho(switch, short = 'i')]
#[argh(switch, short = 'i')]
interactive: bool,

/// enable TLS (automatically inferred for HTTP/S)
#[cargho(switch)]
#[argh(switch)]
tls: bool,

/// the path to a directory from which proto sources can be imported, for use with --proto flags.
#[cargho(option, arg_name = "dir")]
#[argh(option, arg_name = "dir")]
proto_dir: Vec<PathBuf>,

/// pass proto files used for payload forming
#[cargho(option, short = 'p', arg_name = "file")]
#[argh(option, short = 'p', arg_name = "file")]
proto: Vec<PathBuf>,

#[cargho(subcommand)]
#[argh(subcommand)]
pub nested: SubCommand,
}

Expand Down Expand Up @@ -125,7 +125,7 @@ impl Opts {
}

#[derive(FromArgs, PartialEq, Debug)]
#[cargho(subcommand)]
#[argh(subcommand)]
pub enum SubCommand {
Version(Version),
Take(Take),
Expand All @@ -137,118 +137,118 @@ pub enum SubCommand {

/// Returns CARGO_PKG_VERSION
#[derive(FromArgs, PartialEq, Debug)]
#[cargho(subcommand, name = "version")]
#[argh(subcommand, name = "version")]
pub struct Version {
/// returns cargo package version, this is a temporary cargho workaround
#[cargho(switch)]
/// returns cargo package version, this is a temporary argh workaround
#[argh(switch)]
version: bool,
}

/// Takes a single frame, emitting the request then validating the returned response
#[derive(FromArgs, PartialEq, Debug)]
#[cargho(subcommand, name = "take")]
#[cargho(
#[argh(subcommand, name = "take")]
#[argh(
example = "Echo the origin `${{IP}}` that gets written to the cut register from the httpbin.org POST request:
$ dark --cut-out >(jq .IP) take ./test_data/post.01s.body.fr.json"
)]
pub struct Take {
/// path of the frame to process
#[cargho(positional)]
#[argh(positional)]
frame: PathBuf,

/// filepath of input cut file
#[cargho(option, short = 'c')]
#[argh(option, short = 'c')]
cut: Option<PathBuf>,

/// ignore looking for a cut file when running take
#[cargho(switch, short = 'n')]
#[argh(switch, short = 'n')]
no_cut: bool,

/// output of take file
#[cargho(option, short = 'o', arg_name = "file")]
#[argh(option, short = 'o', arg_name = "file")]
take_out: Option<PathBuf>,

/// filepath of merge cuts
#[cargho(positional)]
#[argh(positional)]
merge_cuts: Vec<String>,
}

/// Attempts to play through an entire Reel sequence running a take for every frame in the sequence
#[derive(FromArgs, PartialEq, Debug)]
#[cargho(subcommand, name = "record")]
#[cargho(
#[argh(subcommand, name = "record")]
#[argh(
example = "Step through the httpbin test in [-i]nteractive mode:
$ dark -i record ./test_data post",
example = "Echo the origin `${{IP}}` that gets written to the cut register from the httpbin.org POST request:
$ dark --cut-out >(jq .IP) record ./test_data post"
)]
pub struct Record {
/// directory path where frames and (if no explicit cut is provided) the cut are to be found
#[cargho(positional)]
#[argh(positional)]
reel_path: PathBuf,

/// name of the reel, used to find corresponding frames for the path provided
#[cargho(positional)]
#[argh(positional)]
reel_name: String,

/// filepath of input cut file
#[cargho(option, short = 'c')]
#[argh(option, short = 'c')]
cut: Option<PathBuf>,

/// repeatable component reel pattern using an ampersand separator: --component "<dir>&<reel_name>"
#[cargho(option, short = 'b')]
#[argh(option, short = 'b')]
component: Vec<String>,

/// filepath of merge cuts
#[cargho(positional)]
#[argh(positional)]
merge_cuts: Vec<String>,

/// output directory for successful takes
#[cargho(option, short = 'o')]
#[argh(option, short = 'o')]
take_out: Option<PathBuf>,

/// the range (inclusive) of frames that a record session will use, colon separated: --range <start>:<end> --range <start>:
#[cargho(option, short = 'r')]
#[argh(option, short = 'r')]
range: Option<String>,

/// client request timeout in seconds, --timeout 0 disables request timeout [default: 30]
#[cargho(option, short = 't', default = "30")]
#[argh(option, short = 't', default = "30")]
timeout: u64,

/// print timestamp at take start, error return, and reel completion
#[cargho(switch, short = 's')]
#[argh(switch, short = 's')]
timestamp: bool,

/// print total time elapsed from record start to completion
#[cargho(switch, short = 'd')]
#[argh(switch, short = 'd')]
duration: bool,
}

/// Attempts to play through an entire VirtualReel sequence running a take for every frame in the sequence
#[derive(FromArgs, PartialEq, Debug)]
#[cargho(subcommand, name = "vrecord")]
#[cargho(example = "Run the post reel in a v-reel setup:
#[argh(subcommand, name = "vrecord")]
#[argh(example = "Run the post reel in a v-reel setup:
$ {command_name} ./test_data/post.vr.json
$ {command_name} ./test_data/alt_post.vr.json")]
pub struct VirtualRecord {
/// filepath or json string of VirtualReel
#[cargho(positional)]
#[argh(positional)]
vreel: String,

/// output directory for successful takes
#[cargho(option, short = 'o')]
#[argh(option, short = 'o')]
take_out: Option<PathBuf>,

/// client request timeout in seconds, --timeout 0 disables request timeout [default: 30]
#[cargho(option, short = 't', default = "30")]
#[argh(option, short = 't', default = "30")]
timeout: u64,

/// print timestamp at take start, error return, and reel completion
#[cargho(switch, short = 's')]
#[argh(switch, short = 's')]
timestamp: bool,

/// print total time elapsed from record start to completion
#[cargho(switch, short = 'd')]
#[argh(switch, short = 'd')]
duration: bool,
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use darkroom::{
use std::io::{self, Write};

fn main() -> Result<(), Error> {
let args: Command = cargho::from_env();
let args: Command = argh::from_env();

let opts: Opts = Opts::new(&args);
let base_params = args.base_params();
Expand Down
10 changes: 5 additions & 5 deletions src/man.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{anyhow, Error};
use cargho::FromArgs;
use argh::FromArgs;
use mdcat::{push_tty, Environment, ResourceAccess, Settings, TerminalCapabilities, TerminalSize};
use minus::{page_all, Pager};
use pulldown_cmark::{Event, Options, Parser, Tag};
Expand Down Expand Up @@ -85,8 +85,8 @@ const ENTRY_DOCSTRING: &str = r#"<entry>:
const FILMREEL_REPO: &str = "https://github.com/mkatychev/filmReel/blob/master/";

#[derive(FromArgs, PartialEq, Debug)]
#[cargho(subcommand, name = "man")]
#[cargho(note = r#"<entry>:
#[argh(subcommand, name = "man")]
#[argh(note = r#"<entry>:
readme
frame
cut
Expand All @@ -103,10 +103,10 @@ validation"#)]
/// return a given manual entry
pub struct Man {
/// the manual entry to specify
#[cargho(positional, default = "String::from(\"readme\")")]
#[argh(positional, default = "String::from(\"readme\")")]
pub entry: String,
/// return the TLDR variant of: reel, frame, and cut
#[cargho(switch, short = 'q')]
#[argh(switch, short = 'q')]
pub quick: bool,
}

Expand Down

0 comments on commit 2cb78eb

Please sign in to comment.