Skip to content

Commit

Permalink
Better help message to waj command line.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgautierfr committed Feb 18, 2024
1 parent 3fd294a commit 290ef66
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
22 changes: 16 additions & 6 deletions src/create.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
use anyhow::Result;
use clap::{Parser, ValueHint};
use std::cell::Cell;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::PathBuf;
use std::rc::Rc;
use std::sync::Arc;

#[derive(clap::Parser)]
#[derive(Parser)]
pub struct Options {
// Archive name to create
#[arg(short = 'f', long = "file", value_parser)]
outfile: PathBuf,

#[arg(long, required = false)]
/// Remove STRIP_PREFIX from the entries' name added to the archive.
#[arg(long, required = false, value_hint=ValueHint::DirPath)]
strip_prefix: Option<PathBuf>,

#[arg(short = 'C', required = false)]
/// Move to BASE_DIR before starting adding content to arx archive.
///
/// Argument `INFILES` or `STRIP_PREFIX` must be relative to `BASE_DIR`.
#[arg(short = 'C', required = false, value_hint=ValueHint::DirPath)]
base_dir: Option<PathBuf>,

// Input
#[arg(value_parser)]
/// Input files/directories
///
/// This is an option incompatible with `FILE_LIST`.
#[arg(value_parser, group = "input", value_hint=ValueHint::AnyPath)]
infiles: Vec<PathBuf>,

#[arg(short = 'L', long = "file-list")]
/// Get the list of files/directories to add from the FILE_LIST (incompatible with INFILES)
///
/// This is an option incompatible with `INFILES`.
#[arg(short = 'L', long = "file-list", group = "input", verbatim_doc_comment, value_hint=ValueHint::FilePath)]
file_list: Option<PathBuf>,

#[arg(short = '1', long, required = false, default_value_t = false, action)]
Expand Down
6 changes: 4 additions & 2 deletions src/list.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use anyhow::{Context, Result};
use clap::Parser;
use clap::{Parser, ValueHint};
use std::path::PathBuf;

/// List the content in the archive.
#[derive(Parser)]
pub struct Options {
#[arg(value_parser)]
/// Archive to read
#[arg(value_parser, value_hint=ValueHint::FilePath)]
infile: PathBuf,

#[arg(from_global)]
Expand Down
7 changes: 5 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::path::PathBuf;
use std::process::ExitCode;

#[derive(Parser)]
#[clap(name = "waj", author, version, about, long_about=None)]
#[command(name = "waj", author, version, about, long_about=None)]
struct Cli {
/// Set verbose level. Can be specify several times to augment verbose level.
#[arg(short, long, action=clap::ArgAction::Count, global=true)]
Expand Down Expand Up @@ -47,12 +47,15 @@ enum Commands {
List(list::Options),
}

/// Serve the waj archive on the web.
#[derive(Parser)]
struct Serve {
/// Archive to serve
#[arg(value_parser)]
infile: PathBuf,

#[arg(value_parser)]
/// On which address serve the archive.
#[arg(value_parser, default_value = "localhost:1234")]
address: String,

#[arg(from_global)]
Expand Down

0 comments on commit 290ef66

Please sign in to comment.