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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ jobs:
&& cargo test --locked -p wright-consumer --test consumer

- name: Install pinned OPY provider
run: target/debug/wright provider update opy --version 0.1.38
run: target/debug/wright update provider opy --version 0.1.38

- name: Compile OPY via provider
run: >-
Expand Down
50 changes: 5 additions & 45 deletions crates/wright-cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::path::PathBuf;

use crate::serve::ServeArgs;
use crate::update::UpdateArgs;
use clap::{Args, Parser, Subcommand, ValueEnum};

/// The top-level command model used by parsing, help, and completion.
Expand Down Expand Up @@ -61,8 +62,8 @@ FINDING SELECTION (check, analyze, lint):
--max <N> Report at most N findings (withheld counts are shown)

UPDATE OPTIONS:
--check Check for an update without modifying the installation
--version <VERSION> Install an exact version instead of the latest stable release";
--check Resolve update targets and report availability without modifying anything
--version <VERSION> Install an exact version (`update self`, `update provider <NAME>`)";

#[derive(Debug, Subcommand)]
pub(crate) enum Command {
Expand All @@ -82,16 +83,11 @@ pub(crate) enum Command {
Inspect(CommonArgs),
/// Generate static shell completion from the command model.
Completion(CompletionArgs),
/// Update a standalone installation.
/// Update Wright-managed components: a standalone installation and
/// installed first-party providers.
Update(UpdateArgs),
/// Manage first-party language providers.
Provider(ProviderArgs),
/// Serve the versioned agent contract over stdio or JSON-RPC 2.0.
Serve(ServeArgs),
/// Show the top-level help.
Help,
/// Show version and result-contract metadata.
Version,
/// Compare two Workshop texts using canonical WIR semantics (internal gate command).
#[command(name = "semantic-compare", hide = true)]
SemanticCompare(SemanticCompareArgs),
Expand Down Expand Up @@ -256,42 +252,6 @@ impl CompletionInstallArgs {
}
}

#[derive(Debug, Args)]
pub(crate) struct UpdateArgs {
/// Check for an update without modifying the installation.
#[arg(long)]
pub(crate) check: bool,
/// Install an exact version instead of the latest stable release.
#[arg(long, value_name = "VERSION")]
pub(crate) version: Option<String>,
}

#[derive(Debug, Args)]
pub(crate) struct ProviderArgs {
#[command(subcommand)]
pub(crate) command: ProviderCommand,
}

#[derive(Debug, Subcommand)]
pub(crate) enum ProviderCommand {
/// Install or update a first-party provider.
Update(ProviderUpdateArgs),
}

#[derive(Debug, Args)]
pub(crate) struct ProviderUpdateArgs {
/// The provider to install.
pub(crate) provider: ProviderNameArg,
/// Install an exact release instead of the latest stable release.
#[arg(long, value_name = "VERSION")]
pub(crate) version: Option<String>,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
pub(crate) enum ProviderNameArg {
Opy,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
pub(crate) enum SourceKindArg {
Auto,
Expand Down
33 changes: 3 additions & 30 deletions crates/wright-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ use wright_driver::config::{InputSpec, LintConfig, OutputFormat, SessionConfig,
use wright_driver::result::exit;
use wright_driver::source_provider::SourceBackend;

use crate::cli::{
Cli, Command, CommonArgs, ConvertTargetArg, OutputFormatArg, ProviderCommand, ProviderNameArg,
};
use crate::cli::{Cli, Command, CommonArgs, ConvertTargetArg, OutputFormatArg};

/// The CLI name and version banner.
pub const CLI_NAME: &str = "wright";
Expand Down Expand Up @@ -52,16 +50,12 @@ fn main() -> ExitCode {
}

match cli.command {
None | Some(Command::Help) => {
None => {
let mut command = Cli::command();
let _ = command.print_help();
println!();
ExitCode::SUCCESS
}
Some(Command::Version) => {
println!("{}", version_banner());
ExitCode::SUCCESS
}
Some(Command::SemanticCompare(args)) => run_semantic_compare(args),
Some(Command::Serve(args)) => serve::run(args),
Some(Command::Completion(args)) => match args.subcommand {
Expand All @@ -88,31 +82,13 @@ fn main() -> ExitCode {
}
},
},
Some(Command::Update(args)) => match update::run(args.check, args.version.as_deref()) {
Some(Command::Update(args)) => match update::run(&args) {
Ok(code) => ExitCode::from(code),
Err(error) => {
eprintln!("wright: {}", error.message());
ExitCode::from(error.exit_code())
}
},
Some(Command::Provider(args)) => match args.command {
ProviderCommand::Update(update) => match update.provider {
ProviderNameArg::Opy => match provider::update(update.version.as_deref()) {
Ok(resolved) => {
println!(
"installed first-party OPY provider {} at {}",
resolved.version.as_deref().unwrap_or("local"),
resolved.executable.display()
);
ExitCode::SUCCESS
}
Err(error) => {
eprintln!("wright: {}: {}", error.code(), error);
ExitCode::from(error.exit_code())
}
},
},
},
Some(command) => run_workflow(command),
}
}
Expand Down Expand Up @@ -204,10 +180,7 @@ fn run_workflow(command: Command) -> ExitCode {
),
Command::Completion(_)
| Command::Update(_)
| Command::Provider(_)
| Command::Serve(_)
| Command::Help
| Command::Version
| Command::SemanticCompare(_) => {
unreachable!("non-workflow command handled before run_workflow")
}
Expand Down
10 changes: 10 additions & 0 deletions crates/wright-cli/src/provider.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
use wright_driver::{OpyProviderConfig, OpyProviderError, ResolvedOpyProvider};

/// The first-party OPY provider recorded in the provider store, if usable.
pub(crate) fn installed() -> Result<Option<ResolvedOpyProvider>, OpyProviderError> {
OpyProviderConfig::default().installed()
}

/// The latest published OPY provider version (pointer fetch only).
pub(crate) fn latest_version() -> Result<String, OpyProviderError> {
OpyProviderConfig::default().latest_version()
}

/// Explicitly install/update the first-party OPY provider.
pub(crate) fn update(version: Option<&str>) -> Result<ResolvedOpyProvider, OpyProviderError> {
OpyProviderConfig::default().update(version)
Expand Down
Loading
Loading