use auto implementation for the version command

This commit is contained in:
naskya 2024-06-25 14:08:54 +09:00
parent 3493eeb29e
commit d5f42f58d2
Signed by: naskya
GPG key ID: 712D413B3A9FED5C
4 changed files with 4 additions and 15 deletions

2
Cargo.lock generated
View file

@ -520,7 +520,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
[[package]] [[package]]
name = "firefish-cli" name = "fishctl"
version = "0.1.0-alpha.1" version = "0.1.0-alpha.1"
dependencies = [ dependencies = [
"chrono", "chrono",

View file

@ -1,14 +1,11 @@
[package] [package]
name = "firefish-cli" name = "fishctl"
description = "CLI tool for configuring Firefish"
version = "0.1.0-alpha.1" version = "0.1.0-alpha.1"
rust-version = "1.74" rust-version = "1.74"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
[[bin]]
name = "fishctl"
path = "src/main.rs"
[dependencies] [dependencies]
chrono = "0.4" chrono = "0.4"
clap = { version = "4.5", features = ["derive"] } clap = { version = "4.5", features = ["derive"] }

View file

@ -2,7 +2,6 @@
mod config; mod config;
mod generate; mod generate;
mod version;
use clap::{Parser, Subcommand}; use clap::{Parser, Subcommand};
@ -16,6 +15,7 @@ pub(crate) enum Error {
} }
#[derive(Parser)] #[derive(Parser)]
#[command(version, about)]
struct Args { struct Args {
#[command(subcommand)] #[command(subcommand)]
command: Commands, command: Commands,
@ -23,8 +23,6 @@ struct Args {
#[derive(Subcommand)] #[derive(Subcommand)]
enum Commands { enum Commands {
/// Print fishctl version
Version,
/// Modify or validate the config files /// Modify or validate the config files
#[command(subcommand)] #[command(subcommand)]
Config(config::Commands), Config(config::Commands),
@ -37,7 +35,6 @@ pub(super) async fn run() -> Result<(), Error> {
let args = Args::parse(); let args = Args::parse();
match args.command { match args.command {
Commands::Version => version::run(),
Commands::Config(subcommand) => config::run(subcommand).await?, Commands::Config(subcommand) => config::run(subcommand).await?,
Commands::Generate(subcommand) => generate::run(subcommand)?, Commands::Generate(subcommand) => generate::run(subcommand)?,
} }

View file

@ -1,5 +0,0 @@
//! `version` subcommand
pub(super) fn run() {
println!("v{}", env!("CARGO_PKG_VERSION"));
}