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
79 changes: 79 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ libc = "0.2"
serde = "1"
serde_json = "1"
sha2 = "0.10"
flate2 = "1"
tar = "0.4"
ureq = "2"
zip = { version = "2", default-features = false, features = ["deflate"] }
wright-analyzer = { path = "crates/wright-analyzer" }
wright-core = { path = "crates/wright-core" }
wright-driver = { path = "crates/wright-driver" }
Expand Down
32 changes: 32 additions & 0 deletions crates/wright-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ WORKFLOW OPTIONS:
--target <TARGET> Reconstruction target for convert: opy|ostw
--locale <LOCALE> Workshop client locale override
--root <DIR> Include/project root for source inputs
--opy-provider <PATH> Explicit local first-party OPY provider executable
--profile <PROFILE> WIR transformation policy: off|compat|aggressive
-o, --output <PATH> Write compiled output to PATH (compile only)
-f, --format <FMT> Output format: text|json
Expand Down Expand Up @@ -73,6 +74,8 @@ pub(crate) enum Command {
Completion(CompletionArgs),
/// Update a standalone installation.
Update(UpdateArgs),
/// Manage first-party language providers.
Provider(ProviderArgs),
/// Show the top-level help.
Help,
/// Show version and result-contract metadata.
Expand Down Expand Up @@ -111,6 +114,9 @@ pub(crate) struct CommonArgs {
/// Include/project root for source inputs.
#[arg(long, value_name = "DIR")]
pub(crate) root: Option<PathBuf>,
/// Explicit local first-party OPY provider executable.
#[arg(long, value_name = "PATH")]
pub(crate) opy_provider: Option<PathBuf>,
/// WIR transformation policy.
#[arg(long, value_enum, default_value_t = ProfileArg::Off)]
pub(crate) profile: ProfileArg,
Expand Down Expand Up @@ -196,6 +202,32 @@ pub(crate) struct UpdateArgs {
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: 31 additions & 2 deletions crates/wright-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
mod cli;
mod completion;
mod present;
mod provider;
mod update;

use std::io::Write;
Expand All @@ -13,7 +14,9 @@ use clap::{CommandFactory, Parser};
use wright_driver::config::{InputSpec, OutputFormat, SessionConfig, SourceKind};
use wright_driver::result::exit;

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

/// The CLI name and version banner.
pub const CLI_NAME: &str = "wright";
Expand Down Expand Up @@ -89,6 +92,24 @@ fn main() -> ExitCode {
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 @@ -156,7 +177,11 @@ fn run_workflow(command: Command) -> ExitCode {
present::Presentation::from_common(&args),
None,
),
Command::Completion(_) | Command::Update(_) | Command::Help | Command::Version => {
Command::Completion(_)
| Command::Update(_)
| Command::Provider(_)
| Command::Help
| Command::Version => {
unreachable!("non-workflow command handled before run_workflow")
}
};
Expand Down Expand Up @@ -230,6 +255,10 @@ fn config_from_common(common: &CommonArgs) -> SessionConfig {
},
locale: common.locale.clone(),
root: common.root.clone(),
opy_provider: wright_driver::OpyProviderConfig {
executable: common.opy_provider.clone(),
..wright_driver::OpyProviderConfig::default()
},
format: match common.format {
OutputFormatArg::Text => OutputFormat::Text,
OutputFormatArg::Json => OutputFormat::Json,
Expand Down
8 changes: 8 additions & 0 deletions crates/wright-cli/src/provider.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! First-party language-provider management commands.

use wright_driver::{OpyProviderConfig, OpyProviderError, ResolvedOpyProvider};

/// Explicitly install/update the first-party OPY provider.
pub(crate) fn update(version: Option<&str>) -> Result<ResolvedOpyProvider, OpyProviderError> {
OpyProviderConfig::default().update(version)
}
4 changes: 4 additions & 0 deletions crates/wright-driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
sha2.workspace = true
flate2.workspace = true
tar.workspace = true
ureq.workspace = true
zip.workspace = true
wright-analyzer.workspace = true
wright-core.workspace = true
wright-ir.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions crates/wright-driver/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ pub struct SessionConfig {
/// locate the mock provider through the `LPP_MOCK_PROVIDER`
/// environment variable).
pub providers: wright_lpp::ProviderRegistry,
/// First-party OPY provider resolution settings (#244).
pub opy_provider: crate::opy_provider::OpyProviderConfig,
}

impl Default for SessionConfig {
Expand All @@ -144,6 +146,7 @@ impl Default for SessionConfig {
profile: wright_transform::Profile::Off,
lint: LintConfig::default(),
providers: wright_lpp::ProviderRegistry::default(),
opy_provider: crate::opy_provider::OpyProviderConfig::default(),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/wright-driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub mod diag;
pub mod edit;
pub mod input;
pub mod opy;
pub mod opy_provider;
pub mod progress;
pub mod provider_edit;
pub mod result;
Expand All @@ -27,6 +28,9 @@ pub mod workshop_provider;
pub use config::{InputSpec, LintConfig, OutputFormat, SessionConfig, SourceKind};
pub use diag::{Diagnostic, Origin, Position, Severity, SourceSpan, Stage};
pub use input::{ResolvedInput, sha256_hex};
pub use opy_provider::{
OpyProviderConfig, OpyProviderError, OpyProviderResolver, ResolvedOpyProvider,
};
pub use progress::{ProgressEvent, ProgressObserver, ProgressPhase, ProgressUnit};
pub use result::{
AnalyzeResult, CheckResult, CompileResult, CompiledOutput, ConvertResult, ConvertTarget,
Expand Down
Loading