Skip to content

Commit

Permalink
Make command required.
Browse files Browse the repository at this point in the history
  • Loading branch information
nekitdev committed Nov 1, 2024
1 parent 4f18fe6 commit a6450c9
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct App {
pub globals: Globals,
/// The subcommand to run, if any.
#[command(subcommand)]
pub command: Option<Command>,
pub command: Command,
}

/// Represents sources of errors that can occur during application runs.
Expand Down Expand Up @@ -155,19 +155,17 @@ impl App {
discover().map_err(Error::discover)?
};

if let Some(command) = self.command {
match command {
Command::Build(build) => {
build.run(workspace).map_err(Error::build)?;
}
Command::Preview(preview) => {
preview.run(workspace).map_err(Error::preview)?;
}
Command::Create(create) => {
let directory = workspace.config.paths.directory;

create.run(directory).map_err(Error::create)?;
}
match self.command {
Command::Build(build) => {
build.run(workspace).map_err(Error::build)?;
}
Command::Preview(preview) => {
preview.run(workspace).map_err(Error::preview)?;
}
Command::Create(create) => {
let directory = workspace.config.paths.directory;

create.run(directory).map_err(Error::create)?;
}
};

Expand Down

0 comments on commit a6450c9

Please sign in to comment.