Skip to content

Commit

Permalink
Make eval an explicit subcommand and restructure the CLI somewhat (#…
Browse files Browse the repository at this point in the history
…1632)

* Make `eval` CLI explicit and remove `-f`

* Implement multiple file inputs as merging

* Use `add_string` instead of `add_term`

* `format` cannot create files anymore

* Update snapshot tests

* Separate customize mode from the `export` subcommand

* Decouple customize mode from export and make it available for every evaluation

* Disable an `unused_mut` warning

* Apply suggestions from code review

Co-authored-by: jneem <[email protected]>

* Add a short option for `export --format`

* Update cli/src/eval.rs

Co-authored-by: Yann Hamdaoui <[email protected]>

---------

Co-authored-by: jneem <[email protected]>
Co-authored-by: Yann Hamdaoui <[email protected]>
  • Loading branch information
3 people authored Sep 26, 2023
1 parent 7dd1046 commit 0433886
Show file tree
Hide file tree
Showing 117 changed files with 905 additions and 788 deletions.
18 changes: 3 additions & 15 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! Command-line options and subcommands.
use std::path::PathBuf;

use git_version::git_version;

Expand Down Expand Up @@ -39,34 +38,23 @@ pub struct Options {
pub global: GlobalOptions,

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

#[derive(clap::Parser, Debug)]
pub struct GlobalOptions {
#[cfg(debug_assertions)]
/// Skips the standard library import. For debugging only. This does not affect REPL
#[arg(long, global = true)]
pub nostdlib: bool,

/// Configure when to output messages in color
#[arg(long, global = true, value_enum, default_value_t)]
pub color: clap::ColorChoice,

/// Input file, omit to read from stdin
#[arg(long, short, global = true)]
pub file: Option<PathBuf>,
}

/// Available subcommands.
#[derive(clap::Subcommand, Debug)]
pub enum Command {
/// Evaluate a Nickel program and pretty-print the result.
#[command(hide = true)]
Eval(EvalCommand),

/// Converts the parsed representation (AST) back to Nickel source code and prints it. Used for
/// debugging purpose
/// Converts the parsed representation (AST) back to Nickel source code and
/// prints it. Used for debugging purpose
PprintAst(PprintAstCommand),
/// Exports the result to a different format
Export(ExportCommand),
Expand Down
Loading

0 comments on commit 0433886

Please sign in to comment.