mirror of
https://github.com/supleed2/omg-rs.git
synced 2024-12-22 05:35:52 +00:00
Move Cli and Commands definitions into cli module
This commit is contained in:
parent
2d29a930af
commit
168f90b9a8
35
src/cli.rs
Normal file
35
src/cli.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
use clap::{Parser, Subcommand};
|
||||
|
||||
#[derive(Parser)]
|
||||
pub struct Cli {
|
||||
/// Set a custom username
|
||||
#[clap(short, long)]
|
||||
pub username: Option<String>,
|
||||
|
||||
#[clap(subcommand)]
|
||||
pub command: Option<Commands>,
|
||||
|
||||
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||
pub verbose: u8,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum Commands {
|
||||
Auth {
|
||||
api_key: String,
|
||||
},
|
||||
Weblog {
|
||||
#[arg(short, long)]
|
||||
yay: u8,
|
||||
|
||||
#[arg(short, long)]
|
||||
nay: Option<u8>,
|
||||
},
|
||||
Status {
|
||||
#[arg(long)]
|
||||
message: String,
|
||||
|
||||
/// Does this explain it?
|
||||
req: String,
|
||||
},
|
||||
}
|
39
src/main.rs
39
src/main.rs
|
@ -1,49 +1,18 @@
|
|||
use anyhow::Context;
|
||||
use clap::{Parser, Subcommand};
|
||||
use clap::Parser;
|
||||
use directories::ProjectDirs;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fs::read_to_string;
|
||||
|
||||
mod cli;
|
||||
use cli::{Cli, Commands};
|
||||
|
||||
#[derive(Default, Deserialize, Serialize)]
|
||||
struct Config {
|
||||
api_key: Option<String>,
|
||||
username: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Cli {
|
||||
/// Set a custom username
|
||||
#[clap(short, long)]
|
||||
username: Option<String>,
|
||||
|
||||
#[clap(subcommand)]
|
||||
command: Option<Commands>,
|
||||
|
||||
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||
verbose: u8,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Commands {
|
||||
Auth {
|
||||
api_key: String,
|
||||
},
|
||||
Weblog {
|
||||
#[arg(short, long)]
|
||||
yay: u8,
|
||||
|
||||
#[arg(short, long)]
|
||||
nay: Option<u8>,
|
||||
},
|
||||
Status {
|
||||
#[arg(long)]
|
||||
message: String,
|
||||
|
||||
/// Does this explain it?
|
||||
req: String,
|
||||
},
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let cli = Cli::parse();
|
||||
|
||||
|
|
Loading…
Reference in a new issue