Skip to content
Draft
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
140 changes: 9 additions & 131 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ path-clean = "1.0.1"
regex = "1.6.0"
serde_yaml = "0.9.34"
serde_json = "1"
structopt = "0.3.11"
clap = { version = "4", features = ["derive"] }
thiserror = "2.0"
tokio = { version = "1.11", features = ["full"] }
toml = "0.8.14"
Expand Down
18 changes: 11 additions & 7 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,20 @@
'';
};
systems = builtins.attrNames inputs.holonix.devShells;
perSystem = { inputs', self', config, system, pkgs, lib, ... }: {
perSystem = { inputs', self', config, system, pkgs, lib, ... }:
let
pkgsWithRust = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
rustToolchain = pkgsWithRust.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
in
{
formatter = pkgs.nixpkgs-fmt;

packages.hc-scaffold =
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
pkgs = pkgsWithRust;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
crateInfo = craneLib.crateNameFromCargoToml { cargoToml = ./Cargo.toml; };

Expand Down Expand Up @@ -107,7 +111,7 @@
};

devShells.ci = pkgs.mkShell {
packages = [ inputs'.holonix.packages.rust self'.packages.hc-scaffold ];
packages = [ rustToolchain self'.packages.hc-scaffold ];
};
};
};
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.88.0"
channel = "1.89.0"
components = ["rustfmt", "clippy"]
profile = "minimal"
4 changes: 2 additions & 2 deletions src/bin/hc-scaffold.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use clap::Parser;
use colored::Colorize;
use holochain_scaffolding_cli::cli::HcScaffold;
use structopt::StructOpt;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
if let Err(e) = HcScaffold::from_args().run().await {
if let Err(e) = HcScaffold::parse().run().await {
eprintln!("{}", e.to_string().red());
}
Ok(())
Expand Down
20 changes: 12 additions & 8 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use crate::scaffold::config::ScaffoldConfig;
use crate::scaffold::example::ExampleType;
use crate::scaffold::web_app::template_type::TemplateType;

use clap::Parser;
use colored::Colorize;
use std::{path::Path, str::FromStr};
use structopt::StructOpt;

mod collection;
mod dna;
Expand All @@ -19,24 +19,28 @@ mod template;
mod web_app;
mod zome;

#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
#[command(version)]
pub struct HcScaffold {
#[structopt(short, long, parse(try_from_str = TemplateType::from_str))]
#[arg(short, long, value_parser = TemplateType::from_str)]
/// The template to use for the hc-scaffold commands.
/// Can either be an option from the built-in templates: "vanilla", "svelte", "headless",
/// or a path to a custom template.
template: Option<TemplateType>,

#[structopt(subcommand)]
#[command(subcommand)]
command: HcScaffoldCommand,
}

/// A command-line interface for creating and modifying a Holochain application (hApp).
#[derive(Debug, StructOpt)]
#[structopt(setting = structopt::clap::AppSettings::InferSubcommands)]
#[derive(Debug, clap::Subcommand)]
#[command(infer_subcommands = true)]
pub enum HcScaffoldCommand {
WebApp(web_app::WebApp),
Template(template::Template),
Template {
#[command(subcommand)]
command: template::Template,
},
Dna(dna::Dna),
Zome(zome::Zome),
EntryType(entry_type::EntryType),
Expand All @@ -53,7 +57,7 @@ impl HcScaffold {

match self.command {
HcScaffoldCommand::WebApp(web_app) => web_app.run(&template_type).await,
HcScaffoldCommand::Template(template) => template.run(&template_type),
HcScaffoldCommand::Template { command } => command.run(&template_type),
HcScaffoldCommand::Dna(dna) => dna.run(&template_type),
HcScaffoldCommand::Zome(zome) => zome.run(&template_type),
HcScaffoldCommand::EntryType(entry_type) => entry_type.run(&template_type),
Expand Down
Loading
Loading