Initial commit
This commit is contained in:
74
src/main.rs
Normal file
74
src/main.rs
Normal file
@@ -0,0 +1,74 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Args {
|
||||
// TODO: allow content from stdin and write to stdout
|
||||
|
||||
// TODO: allow disabling use of PATH for command lookups
|
||||
|
||||
/// Input file
|
||||
input: PathBuf,
|
||||
|
||||
/// Output file
|
||||
output: Option<PathBuf>,
|
||||
|
||||
/// Atomically write to output file
|
||||
#[arg(short, long)]
|
||||
atomic: bool,
|
||||
|
||||
/// Create a backup of the original file
|
||||
#[arg(short, long)]
|
||||
backup: bool,
|
||||
|
||||
/// Backup suffix
|
||||
#[arg(long, default_value = ".bak")]
|
||||
backup_suffix: String,
|
||||
|
||||
/// Make parent directories if they don't exist
|
||||
#[arg(short = 'p', long)]
|
||||
mkdir: bool,
|
||||
|
||||
/// Set mode of output file
|
||||
#[arg(long, default_value = "0644")] // TODO: set value parser
|
||||
mode: u32,
|
||||
|
||||
/// Set owner of output file (default: current user)
|
||||
#[arg(long)]
|
||||
owner: Option<u32>,
|
||||
|
||||
/// Set group of output file (default: current user's primary group)
|
||||
#[arg(long)]
|
||||
group: Option<u32>,
|
||||
|
||||
/// Show diff instead of writing to output file
|
||||
#[arg(short, long)]
|
||||
dry_run: bool,
|
||||
}
|
||||
|
||||
// Allow failure modes per substitution:
|
||||
// - ignore
|
||||
// - warn
|
||||
// - error
|
||||
|
||||
// in patterns:
|
||||
// - line number
|
||||
// - literal string
|
||||
// - regex (allow match groups)
|
||||
|
||||
// out patterns:
|
||||
// - literal string
|
||||
// - regex with match groups
|
||||
// - environment variables
|
||||
// - file contents
|
||||
// - sockets/fifo
|
||||
// - file descriptors
|
||||
// - command output
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let args = Args::parse();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user