Skip to content

Commit

Permalink
feat(cli): panic when no subcommand is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
hulxv committed Aug 24, 2024
1 parent b4f639b commit d4f2656
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/target
/node_modules
/dist
target
node_modules
dist
.vscode
6 changes: 5 additions & 1 deletion crates/metassr-utils/src/cache_dir.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use anyhow::Result;
use std::{
collections::HashMap, ffi::OsStr, fs::{self, File}, io::{Read, Write}, path::{Path, PathBuf}
collections::HashMap,
ffi::OsStr,
fs::{self, File},
io::{Read, Write},
path::{Path, PathBuf},
};
use walkdir::WalkDir;

Expand Down
2 changes: 1 addition & 1 deletion metassr-cli/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct Args {
pub log_file: Option<String>,

#[command(subcommand)]
pub commands: Option<Commands>,
pub commands: Commands,
}

#[derive(Debug, ValueEnum, PartialEq, Eq, Clone)]
Expand Down
14 changes: 6 additions & 8 deletions metassr-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async fn main() -> Result<()> {
[Some(DebugMode::All), Some(DebugMode::Metacall)].contains(&args.debug_mode);
let allow_http_debug = [Some(DebugMode::All), Some(DebugMode::Http)].contains(&args.debug_mode);

if let Some(Commands::Create { .. }) = args.commands {
if let Commands::Create { .. } = args.commands {
tracing_subscriber::fmt()
.with_target(false)
.without_time()
Expand All @@ -45,28 +45,26 @@ async fn main() -> Result<()> {
set_var("METACALL_DEBUG", "1");
}
}

match args.commands {
Some(Commands::Build {
Commands::Build {
out_dir,
build_type,
}) => {
} => {
cli::Builder::new(build_type, out_dir).exec()?;
}
Some(Commands::Run { port, serve }) => {
Commands::Run { port, serve } => {
cli::Runner::new(port, serve, allow_http_debug)
.exec()
.await?;
}
Some(Commands::Create {
Commands::Create {
project_name,
version,
description,
template,
}) => {
} => {
cli::Creator::new(project_name, version, description, template).exec()?;
}
_ => {}
};

Ok(())
Expand Down

0 comments on commit d4f2656

Please sign in to comment.