Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Use `qt show` to inspect a single run, `qt list` to see a list of all runs, and
Common commands:

```bash
qt --version
qt run <eval_name>
qt list
qt show <run_id>
Expand Down
2 changes: 2 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ qt show 1

> See the [CLI reference](https://quantiles.io/documentation/reference/cli) for a detailed list of `qt` commands.

Print the installed CLI version with `qt --version`.

### Custom evaluations

Custom evaluations are denoted in the configuration file with `type = "custom_code"`. The `command` array tells the CLI how to execute your eval, and the optional `input` table is merged with any values passed through the `--input` flag, then passed to your script as `QUANTILES_INPUT`. An example is below:
Expand Down
20 changes: 18 additions & 2 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
use clap::{Parser, Subcommand};

pub const VERSION: &str = env!("CARGO_PKG_VERSION");

#[derive(Debug, Parser)]
#[command(name = "qt")]
#[command(
name = "qt",
// By default, clap builds in a `--version` flag that produces output with the version number
// prefixed by the binary name. For example:
//
// qt v0.1.2.
//
// This setting disables this default output, so we can manually output _just_ the actual version
// number, so that agents and scripts don't have to parse out the `qt...` prefix.
disable_version_flag = true,
arg_required_else_help = true
)]
#[command(
about = "A full-featured local-native toolchain for running and analyzing AI evals at scale"
)]
pub struct Cli {
/// Print the qt version.
#[arg(long, exclusive = true)]
pub version: bool,
#[command(subcommand)]
pub command: Command,
pub command: Option<Command>,
}

#[derive(Debug, Subcommand)]
Expand Down
7 changes: 6 additions & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ fn main() -> Result<()> {
async fn async_main(process_start: Instant) -> Result<()> {
let cli = cli::Cli::parse();

match cli.command {
if cli.version {
println!("{}", cli::VERSION);
return Ok(());
}

match cli.command.expect("clap requires a subcommand") {
cli::Command::Init => commands::init().await,
cli::Command::List { json } => commands::list(json).await,
cli::Command::Compare { run_a, run_b, json } => commands::compare(run_a, run_b, json).await,
Expand Down
13 changes: 13 additions & 0 deletions cli/tests/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use assert_cmd::Command;
use predicates::prelude::*;

#[test]
fn version_flag_prints_cargo_package_version_without_a_prefix() {
let expected = predicate::eq(format!("{}\n", env!("CARGO_PKG_VERSION")));

Command::new(assert_cmd::cargo::cargo_bin!("qt"))
.arg("--version")
.assert()
.success()
.stdout(expected);
}
Loading