Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
c12i committed Jun 27, 2024
1 parent c877e5b commit 85bb0ae
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 32 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ FLAGS:
-V, --version Prints version information
OPTIONS:
-p, --package-manager <package-manager> The package manager to use for the hc-scaffold commands. Can be one of
the following: "bun", "npm", "pnpm", or "yarn". When a lockfile is
detected, the respective package manager will be used as the default
value; otherwise, npm will be set as the default [default: npm]
-t, --template <template> The template to use for the hc-scaffold commands Can either be an option
from the built-in templates: "vanilla", "vue", "lit", "svelte", "react",
"headless" Or a path to a custom template
-t, --template <template> The template to use for the hc-scaffold commands Can either be an option from the
built-in templates: "vanilla", "vue", "lit", "svelte", "react", "headless" Or a path to
a custom template
SUBCOMMANDS:
collection Scaffold a collection of entries in an existing zome
Expand Down
41 changes: 22 additions & 19 deletions guides/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ hc-scaffold [OPTIONS] <SUBCOMMAND>

### Flags

- `-h`, `--help`
Prints help information.

- `-V`, `--version`
Prints version information.

- `-h`, `--help`
Prints help information.

### Options

- `-t`, `--template <template>`
Expand Down Expand Up @@ -66,15 +66,15 @@ hc-scaffold collection [FLAGS] [OPTIONS] [ARGS]

#### Flags

- `-h`, `--help`
Prints help information.

- `--no-ui`
Skips UI generation for this collection.

- `-V`, `--version`
Prints version information.

- `-h`, `--help`
Prints help information.

#### Options

- `--dna <dna>`
Expand Down Expand Up @@ -106,11 +106,12 @@ hc-scaffold dna [OPTIONS] [name]

#### Flags

- `-V`, `--version`
Prints version information.

- `-h`, `--help`
Prints help information.

- `-V`, `--version`
Prints version information.

#### Options

Expand All @@ -134,9 +135,6 @@ hc-scaffold entry-type [FLAGS] [OPTIONS] [--] [name]

#### Flags

- `-h`, `--help`
Prints help information.

- `--no-ui`
Skips UI generation for this entry-type, overriding any specified widgets in the `--fields` option.

Expand All @@ -147,6 +145,10 @@ hc-scaffold entry-type [FLAGS] [OPTIONS] [--] [name]
- `-V`, `--version`
Prints version information.

- `-h`, `--help`
Prints help information.


#### Options

- `--crud <crud>`
Expand Down Expand Up @@ -281,17 +283,16 @@ hc-scaffold web-app [FLAGS] [OPTIONS] [ARGS]
- `-F`, `--disable-fast-track`
Whether to skip setting up an initial DNA and its zome(s) after the web app is scaffolded.

- `--setup-nix`
Whether to setup the holonix development environment for this web app.

- `-h`, `--help`
Prints help information.

#### Options

- `--setup-nix`
Whether to setup the holonix development environment for this web app.

- `-p`, `--package-manager <package-manager>`
The package manager to use for scaffolding the web app. Can be one of the following: "bun", "npm", "pnpm", or "yarn". When a lockfile is detected, the respective package manager will be used as the default value; otherwise, npm will be set as the default.
**Default:** `npm`
The package manager to use for scaffolding the web app. Can be one of the following: "bun", "npm", "pnpm", or "yarn".

#### Arguments

Expand Down Expand Up @@ -342,7 +343,7 @@ Scaffolds an example Holochain application to help you get started quickly
**Usage**

```bash
hc-scaffold example [FLAGS] [ARGS]
hc-scaffold example [FLAGS] [OPTIONS] [ARGS]
```

#### Flags
Expand All @@ -353,9 +354,11 @@ hc-scaffold example [FLAGS] [ARGS]
- `-V`, `--version`
Prints version information.


### Options

- `-p`, `--package-manager <package-manager>`
The package manager to use for scaffolding the example. Can be one of the following: "bun", "npm", "pnpm", or "yarn". When a lockfile is detected, the respective package manager will be used as the default value; otherwise, npm will be set as the default.
**Default:** `npm`
The package manager to use for scaffolding the example. Can be one of the following: "bun", "npm", "pnpm", or "yarn".

#### Arguments

Expand Down
4 changes: 2 additions & 2 deletions run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ setup_and_build_happ() {
cleanup_tmp "$1"

cd $TEMPLATE_PATH
hc-scaffold --package-manager yarn --template="$2" web-app "$1" --setup-nix true -F
hc-scaffold --template="$2" web-app "$1" --package-manager yarn --setup-nix true -F
cd "$1"

hc-scaffold dna forum
Expand Down Expand Up @@ -72,7 +72,7 @@ setup_and_build_hello_world() {
cleanup_tmp hello-world

cd $TEMPLATE_PATH
hc-scaffold --package-manager yarn example hello-world
hc-scaffold example --package-manager yarn hello-world
cd hello-world

nix develop --command bash -c "
Expand Down
18 changes: 14 additions & 4 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ pub enum HcScaffoldCommand {
/// Can be one of the following: "bun", "npm", "pnpm", or "yarn".
/// When a lockfile is detected, the respective package manager will be used as the default value;
/// otherwise, npm will be set as the default.
#[structopt(short, long, parse(try_from_str = PackageManager::from_str), default_value="npm")]
package_manager: PackageManager,
#[structopt(short, long, parse(try_from_str = PackageManager::from_str))]
package_manager: Option<PackageManager>,

#[structopt(long = "holo", hidden = true)]
holo_enabled: bool,
Expand Down Expand Up @@ -219,8 +219,8 @@ pub enum HcScaffoldCommand {
/// Can be one of the following: "bun", "npm", "pnpm", or "yarn".
/// When a lockfile is detected, the respective package manager will be used as the default value;
/// otherwise, npm will be set as the default.
#[structopt(short, long, parse(try_from_str = PackageManager::from_str), default_value="npm")]
package_manager: PackageManager,
#[structopt(short, long, parse(try_from_str = PackageManager::from_str))]
package_manager: Option<PackageManager>,

#[structopt(long = "holo", hidden = true)]
holo_enabled: bool,
Expand Down Expand Up @@ -275,6 +275,11 @@ impl HcScaffold {
)?
};

let package_manager = match package_manager {
Some(p) => p,
None => PackageManager::choose()?,
};

let ScaffoldedTemplate {
file_tree,
next_instructions,
Expand Down Expand Up @@ -679,6 +684,11 @@ Add new collections for that entry type with:
.into());
}

let package_manager = match package_manager {
Some(p) => p,
None => PackageManager::choose()?,
};

// Match on example types
let file_tree = match example {
Example::HelloWorld => {
Expand Down

0 comments on commit 85bb0ae

Please sign in to comment.