add --registry-name and --license ()

This commit is contained in:
John Vandenberg 2023-01-18 16:06:35 +08:00 committed by GitHub
parent 44b5ad695d
commit 87e01ff32f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 6 deletions
README.md
progenitor/src

View File

@ -155,6 +155,9 @@ For example:
This will produce a package in the specified directory.
Options `--license` and `--registry-name` may also be used to improve metadata
before publishing the static crate.
The output will use the published `progenitor-client` crate by default
if progenitor was built from a released version. However, when using progenitor
built from the repository, the `progenitor-client` will be inlined into the

View File

@ -36,6 +36,12 @@ struct Args {
/// Target Rust crate version
#[clap(short = 'v', long)]
version: String,
/// Target Rust crate registry
#[clap(long)]
registry_name: Option<String>,
/// Target crate license
#[clap(long, default_value = "SPECIFY A LICENSE BEFORE PUBLISHING")]
license_name: String,
/// SDK interface style
#[clap(value_enum, long, default_value_t = InterfaceArg::Positional)]
@ -132,18 +138,28 @@ fn main() -> Result<()> {
let mut toml = root.clone();
toml.push("Cargo.toml");
let tomlout = format!(
let mut tomlout = format!(
"[package]\n\
name = \"{}\"\n\
version = \"{}\"\n\
edition = \"2021\"\n\
\n\
edition = \"2021\"\n\"
license = \"{}\"\n",
name, version, &args.license_name,
);
if let Some(registry_name) = args.registry_name {
tomlout.extend(
format!("publish = [\"{}\"]\n", registry_name).chars(),
);
}
tomlout.extend(
format!(
"\n\
[dependencies]\n\
{}\n\
\n",
name,
version,
dependencies(builder, args.include_client).join("\n"),
dependencies(builder, args.include_client).join("\n"),
)
.chars(),
);
save(&toml, tomlout.as_str())?;