From 16c7608bcfb876866abd62b65276951ee2a81b54 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Thu, 9 May 2024 13:20:13 +0200 Subject: feat(pkgs/lf-make-map): Add de-serialization to lf mappings --- sys/nixpkgs/pkgs/lf-make-map/src/cli.rs | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'sys/nixpkgs/pkgs/lf-make-map/src/cli.rs') diff --git a/sys/nixpkgs/pkgs/lf-make-map/src/cli.rs b/sys/nixpkgs/pkgs/lf-make-map/src/cli.rs index 7650b39b..a398e451 100644 --- a/sys/nixpkgs/pkgs/lf-make-map/src/cli.rs +++ b/sys/nixpkgs/pkgs/lf-make-map/src/cli.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use clap::{ArgAction, Parser}; +use clap::{ArgAction, Parser, Subcommand}; /// An automatic lf cd mapping generator #[derive(Parser, Debug)] @@ -11,9 +11,6 @@ pub struct Args { #[arg(long, short = 'n', env = "HOME")] pub home_name: PathBuf, - /// The directories to generate mappings for - pub relevant_directories: Vec, - /// The number of directories to generate mappings for, starting from each `relevant_directory` #[arg(long, short, default_value = "2")] pub depth: usize, @@ -25,4 +22,28 @@ pub struct Args { /// Silence all output #[arg(long, short = 'q')] pub quiet: bool, + + #[command(subcommand)] + pub command: Command, +} + +#[derive(Subcommand, Debug)] +pub enum Command { + /// Visualize the generated mappings in a tree + Visualize { + #[command(flatten)] + options: CommandOptions, + }, + + /// Output the generated mappings in a format suitable for the lf config file + Generate { + #[command(flatten)] + options: CommandOptions, + }, +} + +#[derive(Debug, Parser)] +pub struct CommandOptions { + /// The directories to generate mappings for + pub relevant_directories: Vec, } -- cgit 1.4.1