Skip to content

Commit

Permalink
feat: add all field as example value when initing (#209)
Browse files Browse the repository at this point in the history
* feat: add all field as example value when initing

* feat: add multiline description

* feat: change order of build and settings
  • Loading branch information
NicolasGirardot authored Feb 13, 2025
1 parent c223ba0 commit 330c9b9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
24 changes: 19 additions & 5 deletions crates/cli/src/commands/components/init.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use url::Url;

use crate::components::{
boilerplate::{CATEGORY_OPTIONS, LANGUAGE_OPTIONS, SUBCATEGORY_OPTIONS},
manifest::{self, Build, Component, Manifest},
manifest::{self, Build, Component, Manifest, Setting},
};

#[derive(Debug, clap::Parser)]
Expand Down Expand Up @@ -54,10 +56,22 @@ pub async fn run(_opts: Options) -> anyhow::Result<()> {
wit_world_version: "0.4.0".to_string(),
category: *component_category.value,
subcategory: *component_subcategory.value,
description: None,
documentation: None,
repository: None,
settings: Default::default(),
description: Some("Description of\nthe component".to_string()),
documentation: Some(Url::parse("https://www.edgee.cloud/docs/introduction")?),
repository: Some(Url::parse("https://www.github.com/edgee-cloud/edgee")?),
settings: {
let mut fields = std::collections::HashMap::new();
fields.insert(
"example".to_string(),
Setting {
description: Some("Here is a\nstring".to_string()),
required: true,
title: "ExampleConfigField".to_string(),
type_: edgee_api_client::types::ConfigurationFieldType::String,
},
);
fields
},
build: Build {
command: component_language.default_build_command.to_string(),
output_path: std::path::PathBuf::from(""),
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/components/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ pub struct Component {

pub wit_world_version: String,

pub build: Build,

#[serde(default)]
pub settings: HashMap<String, Setting>,

pub build: Build,
}

#[derive(Debug, Clone, Copy, Deserialize, Serialize)]
Expand Down

0 comments on commit 330c9b9

Please sign in to comment.