Skip to content

Commit

Permalink
Update for composable app manifests (#1243)
Browse files Browse the repository at this point in the history
* update golem-exmaples and extend app dynamic help with components and dependencies

* add new-app-component command

* update app manifest schema refs

* make fix
  • Loading branch information
noise64 authored Jan 18, 2025
1 parent 149616e commit 277ae0b
Show file tree
Hide file tree
Showing 24 changed files with 331 additions and 173 deletions.
110 changes: 41 additions & 69 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion golem-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ derive_more = { workspace = true }
dirs = "5.0.1"
futures-util = { workspace = true }
glob = "0.3.1"
golem-examples = "1.1.0"
golem-examples = "1.1.1"
h2 = "0.4.7"
http = { workspace = true }
humansize = { workspace = true }
Expand Down
57 changes: 48 additions & 9 deletions golem-cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ use api_deployment::ApiDeploymentSubcommand;
use clap::{self, Command, Subcommand};
use component::ComponentSubCommand;
use golem_common::uri::oss::uri::ComponentUri;
use golem_examples::cli::NameOrLanguage;
use golem_examples::model::{ComponentName, GuestLanguage, GuestLanguageTier, PackageName};
use golem_wasm_rpc_stubgen::App;
use plugin::PluginSubcommand;
use profile::{ProfileSubCommand, UniversalProfileAdd};
Expand Down Expand Up @@ -104,9 +106,43 @@ pub enum StaticSharedCommand {
#[command(flatten)]
command: diagnose::cli::Command,
},
/// Create a new Golem component from built-in examples
#[command(flatten)]
Examples(golem_examples::cli::Command),

/// Create a new Golem standalone component example project from built-in examples
#[command()]
New {
#[command(flatten)]
name_or_language: NameOrLanguage,

/// The package name of the generated component (in namespace:name format)
#[arg(short, long)]
package_name: Option<PackageName>,

/// The new component's name
component_name: ComponentName,
},

/// Add a new Golem component to a project using Golem Application Manifest
#[command()]
NewAppComponent {
/// The component name (and package name) of the generated component (in namespace:name format)
component_name: PackageName,

/// Component language
#[arg(short, long, alias = "lang")]
language: GuestLanguage,
},

/// Lists the built-in examples available for creating new components
#[command()]
ListExamples {
/// The minimum language tier to include in the list
#[arg(short, long)]
min_tier: Option<GuestLanguageTier>,

/// Filter examples by a given guest language
#[arg(short, long, alias = "lang")]
language: Option<GuestLanguage>,
},
}

impl<Ctx> CliCommand<Ctx> for StaticSharedCommand {
Expand All @@ -116,19 +152,22 @@ impl<Ctx> CliCommand<Ctx> for StaticSharedCommand {
diagnose(command);
Ok(GolemResult::Empty)
}
StaticSharedCommand::Examples(golem_examples::cli::Command::ListExamples {
min_tier,
language,
}) => examples::process_list_examples(min_tier, language),
StaticSharedCommand::Examples(golem_examples::cli::Command::New {
StaticSharedCommand::ListExamples { min_tier, language } => {
examples::list_standalone_examples(min_tier, language)
}
StaticSharedCommand::New {
name_or_language,
package_name,
component_name,
}) => examples::process_new(
} => examples::new(
name_or_language.example_name(),
component_name,
package_name,
),
StaticSharedCommand::NewAppComponent {
component_name,
language,
} => examples::new_app_component(component_name, language),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion golem-cli/src/diagnose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ impl DetectedTool {

pub fn diagnose(command: cli::Command) {
let selected_language = match &command.language {
Some(language) => SelectedLanguage::from_flag(language.clone()),
Some(language) => SelectedLanguage::from_flag(*language),
None => SelectedLanguage::from_env(),
};

Expand Down
Loading

0 comments on commit 277ae0b

Please sign in to comment.