mirror of
https://github.com/pcvolkmer/osc-variant.git
synced 2025-07-03 01:02:55 +00:00
Package deb package containing bash completion
This commit is contained in:
11
src/cli.rs
11
src/cli.rs
@ -22,18 +22,23 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use clap::{Command, CommandFactory, Parser, Subcommand};
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn build_cli() -> Command {
|
||||
Cli::command()
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
#[command(propagate_version = true, arg_required_else_help(true))]
|
||||
pub struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub command: Command,
|
||||
pub cmd: SubCommand,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum Command {
|
||||
pub enum SubCommand {
|
||||
#[command(
|
||||
name = "sha256sum",
|
||||
about = "Berechne SHA256 Prüfsumme für die angegebene Datei"
|
||||
|
14
src/main.rs
14
src/main.rs
@ -37,7 +37,7 @@ use quick_xml::se::Serializer;
|
||||
use serde::Serialize;
|
||||
use sha256::digest;
|
||||
|
||||
use crate::cli::{Cli, Command};
|
||||
use crate::cli::{Cli, SubCommand};
|
||||
use crate::model::onkostar_editor::OnkostarEditor;
|
||||
use crate::profile::Profile;
|
||||
|
||||
@ -111,8 +111,8 @@ fn read_profile(filename: String) -> Result<Profile, FileError> {
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let cli = Cli::parse();
|
||||
|
||||
match cli.command {
|
||||
Command::List {
|
||||
match cli.cmd {
|
||||
SubCommand::List {
|
||||
inputfile,
|
||||
sorted,
|
||||
filter,
|
||||
@ -127,7 +127,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
data.print_list();
|
||||
}
|
||||
Command::Tree {
|
||||
SubCommand::Tree {
|
||||
inputfile,
|
||||
sorted,
|
||||
filter,
|
||||
@ -142,7 +142,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
OnkostarEditor::print_tree(&data);
|
||||
}
|
||||
Command::Modify {
|
||||
SubCommand::Modify {
|
||||
inputfile,
|
||||
profile,
|
||||
outputfile,
|
||||
@ -193,7 +193,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
}
|
||||
}
|
||||
Command::Diff {
|
||||
SubCommand::Diff {
|
||||
inputfile_a,
|
||||
inputfile_b,
|
||||
strict,
|
||||
@ -209,7 +209,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
data_a.print_diff(data_b, strict);
|
||||
}
|
||||
Command::Sha256Sum { inputfile } => {
|
||||
SubCommand::Sha256Sum { inputfile } => {
|
||||
match fs::read_to_string(inputfile.clone()) {
|
||||
Ok(content) => {
|
||||
println!(
|
||||
|
Reference in New Issue
Block a user