Skip to content

Commit 791c37c

Browse files
committed
improve the command line flag remove --yes with --components
1 parent 07af8b5 commit 791c37c

8 files changed

Lines changed: 211 additions & 170 deletions

File tree

.github/workflows/test-installer.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
curl -fsSL https://karate.sh/install.sh | sh -s -- --bin-dir $HOME/.local/bin
1818
echo "$HOME/.local/bin" >> $GITHUB_PATH
1919
20-
- name: Setup Karate (JAR only, use system JRE)
21-
run: karate setup path
20+
- name: Setup Karate (uses system JRE, downloads JAR)
21+
run: karate setup --components jar
2222

2323
- name: Verify installation (system JRE)
2424
run: |
@@ -33,8 +33,8 @@ jobs:
3333
karate smoke.feature
3434
echo "Exit code: $?"
3535
36-
- name: Setup managed JRE
37-
run: karate setup jre
36+
- name: Download managed JRE
37+
run: karate setup --components jre --force
3838

3939
- name: Verify installation (managed JRE)
4040
env:
@@ -62,8 +62,8 @@ jobs:
6262
.\install.ps1 -InstallDir $InstallDir
6363
echo "$InstallDir" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
6464
65-
- name: Setup Karate (JAR only, use system JRE)
66-
run: karate setup path
65+
- name: Setup Karate (uses system JRE, downloads JAR)
66+
run: karate setup --components jar
6767

6868
- name: Verify installation (system JRE)
6969
run: |
@@ -78,8 +78,8 @@ jobs:
7878
karate smoke.feature
7979
echo "Exit code: $LASTEXITCODE"
8080
81-
- name: Setup managed JRE
82-
run: karate setup jre
81+
- name: Download managed JRE
82+
run: karate setup --components jre --force
8383

8484
- name: Verify installation (managed JRE)
8585
env:

aws-amplify/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ <h2>macOS / Linux</h2>
258258
<div class="more-options-content">
259259
<p class="option-label">With auto-setup (downloads JRE + JAR immediately):</p>
260260
<div class="code-block">
261-
<code>curl -fsSL https://karate.sh/install.sh | sh -s -- --yes</code>
262-
<button class="copy-btn" onclick="copyToClipboard('curl -fsSL https://karate.sh/install.sh | sh -s -- --yes', this)">Copy</button>
261+
<code>curl -fsSL https://karate.sh/install.sh | sh -s -- --all</code>
262+
<button class="copy-btn" onclick="copyToClipboard('curl -fsSL https://karate.sh/install.sh | sh -s -- --all', this)">Copy</button>
263263
</div>
264264
</div>
265265
</details>
@@ -276,8 +276,8 @@ <h2>Windows (PowerShell)</h2>
276276
<div class="more-options-content">
277277
<p class="option-label">With auto-setup (downloads JRE + JAR immediately):</p>
278278
<div class="code-block">
279-
<code>iex "& { $(irm https://karate.sh/install.ps1) } -Yes"</code>
280-
<button class="copy-btn" onclick="copyToClipboard('iex \"& { $(irm https://karate.sh/install.ps1) } -Yes\"', this)">Copy</button>
279+
<code>iex "& { $(irm https://karate.sh/install.ps1) } -All"</code>
280+
<button class="copy-btn" onclick="copyToClipboard('iex \"& { $(irm https://karate.sh/install.ps1) } -All\"', this)">Copy</button>
281281
</div>
282282
</div>
283283
</details>

aws-amplify/install.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Karate CLI Installer for Windows
22
# Usage: irm https://karate.sh/install.ps1 | iex
3-
# irm https://karate.sh/install.ps1 | iex -Args '--yes'
3+
# iex "& { $(irm https://karate.sh/install.ps1) } -All"
44
#
55
# Options:
6-
# -Yes Non-interactive, accept defaults
6+
# -All Download JRE + JAR immediately after install
77
# -InstallDir DIR Install to custom directory (default: %LOCALAPPDATA%\Programs\Karate)
88
# -Version VER Install specific version (default: latest)
99

1010
param(
11-
[switch]$Yes,
11+
[switch]$All,
1212
[string]$InstallDir = "$env:LOCALAPPDATA\Programs\Karate",
1313
[string]$Version = "latest",
1414
[switch]$Help
@@ -93,7 +93,7 @@ function Show-Help {
9393
Write-Host " .\install.ps1 [OPTIONS]"
9494
Write-Host ""
9595
Write-Host "Options:"
96-
Write-Host " -Yes Non-interactive, accept defaults"
96+
Write-Host " -All Download JRE + JAR immediately after install"
9797
Write-Host " -InstallDir DIR Install to custom directory"
9898
Write-Host " (default: %LOCALAPPDATA%\Programs\Karate)"
9999
Write-Host " -Version VER Install specific version (default: latest)"
@@ -186,9 +186,9 @@ function Main {
186186
}
187187

188188
# Run setup if requested
189-
if ($Yes) {
189+
if ($All) {
190190
Write-Info "Running karate setup..."
191-
& $binaryPath setup --yes
191+
& $binaryPath setup --all
192192
} else {
193193
Write-Host "Next steps:"
194194
Write-Host ""

aws-amplify/install.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/sh
22
# Karate CLI Installer for Unix/macOS
33
# Usage: curl -fsSL https://karate.sh/install.sh | sh
4-
# curl -fsSL https://karate.sh/install.sh | sh -s -- --yes
4+
# curl -fsSL https://karate.sh/install.sh | sh -s -- --all
55
#
66
# Options:
7-
# --yes Non-interactive, accept defaults
7+
# --all Download JRE + JAR immediately after install
88
# --bin-dir DIR Install to custom directory (default: ~/.local/bin)
99
# --version VER Install specific version (default: latest)
1010

@@ -53,8 +53,8 @@ error() {
5353
# Parse arguments
5454
while [ $# -gt 0 ]; do
5555
case "$1" in
56-
--yes|-y)
57-
AUTO_SETUP="--yes"
56+
--all|-a)
57+
AUTO_SETUP="--all"
5858
shift
5959
;;
6060
--bin-dir)
@@ -71,7 +71,7 @@ while [ $# -gt 0 ]; do
7171
echo "Usage: curl -fsSL https://karate.sh/install.sh | sh -s -- [OPTIONS]"
7272
echo ""
7373
echo "Options:"
74-
echo " --yes, -y Non-interactive, accept defaults"
74+
echo " --all, -a Download JRE + JAR immediately after install"
7575
echo " --bin-dir DIR Install to custom directory (default: ~/.local/bin)"
7676
echo " --version VER Install specific version (default: latest)"
7777
echo " --help, -h Show this help"
@@ -276,7 +276,7 @@ main() {
276276
# Run setup if requested
277277
if [ -n "$AUTO_SETUP" ]; then
278278
info "Running karate setup..."
279-
"${INSTALL_DIR}/karate" setup --yes
279+
"${INSTALL_DIR}/karate" setup --all
280280
else
281281
echo "Next steps:"
282282
echo ""

docs/spec.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ Commands fully implemented in Rust:
9696
| Command | Description |
9797
|---------|-------------|
9898
| `karate setup` | Interactive first-run wizard |
99-
| `karate setup path` | Install CLI to PATH only |
100-
| `karate setup jre` | Install/update JRE only |
101-
| `karate upgrade [--yes] [--version <ver>]` | Update to latest/specific version |
99+
| `karate setup --all` | Install JAR + JRE non-interactively |
100+
| `karate setup --components jar` | Install JAR only (use system JRE) |
101+
| `karate setup --components jre` | Install/update JRE only |
102+
| `karate upgrade [--version <ver>]` | Update to latest/specific version |
102103
| `karate config [--global\|--local\|--show]` | Edit or view configuration |
103104
| `karate jre list` | List installed JREs |
104105
| `karate jre doctor` | Check JRE health |
@@ -132,7 +133,7 @@ Everything else passes through to the JVM:
132133
* Download matching JustJ JRE
133134
* Store in `~/.karate/`
134135
* Offer to add to PATH
135-
* Support automated/non-interactive mode (`--yes`).
136+
* Support automated/non-interactive mode (`--all` or `--components`).
136137
* **Explicit bootstrap required** — running `karate run` without setup shows helpful error.
137138

138139
### **B. Self-Management**
@@ -263,32 +264,38 @@ Runtime Commands (JAR-delegated):
263264
### **setup**
264265

265266
```
266-
karate setup [--yes]
267-
karate setup path [--bin-dir <path>] [--modify-shell-profile]
268-
karate setup jre [--version <ver>]
267+
karate setup [--all] [--components <list>] [--force] [--java-version <ver>]
269268
```
270269

271270
Interactive first-run wizard. Downloads JRE and Karate JAR, offers PATH setup.
272271

273-
**Subcommands:**
274-
* `path` — Only set up PATH/symlinks
275-
* `jre` — Only install/update JRE
276-
277272
**Flags:**
278-
* `--yes` — Non-interactive, accept defaults
273+
* `--all` — Install all components (JAR + JRE) non-interactively
274+
* `--components <list>` — Install specific components (comma-separated: jar, jre)
275+
* `--force` — Force download even if components already installed
276+
* `--java-version <ver>` — Specific Java major version (default: 21)
277+
278+
**Examples:**
279+
```
280+
karate setup # Interactive wizard
281+
karate setup --all # Install everything non-interactively
282+
karate setup --components jar # JAR only (use system JRE)
283+
karate setup --components jre # JRE only
284+
karate setup --components jar,jre --force # Force re-download both
285+
```
279286

280287
---
281288

282289
### **upgrade**
283290

284291
```
285-
karate upgrade [--yes] [--version <ver>]
292+
karate upgrade [--all] [--version <ver>]
286293
```
287294

288295
Check for updates and download new versions.
289296

290297
**Flags:**
291-
* `--yes` — Non-interactive
298+
* `--all` — Non-interactive (upgrade all components)
292299
* `--version <ver>` — Install specific version instead of latest
293300

294301
---
@@ -639,7 +646,7 @@ irm https://karate.sh/install.ps1 | iex
639646
**Implementation:**
640647
- `karate.sh` serves a shell script that detects OS/arch
641648
- Downloads the correct binary from GitHub releases
642-
- Optionally runs `karate setup --yes` for full bootstrap
649+
- Optionally runs `karate setup --all` for full bootstrap
643650
- Provides clear instructions for PATH setup
644651

645652
## **10.2 npm Package**
@@ -678,7 +685,7 @@ karate-npm/
678685
2. Download matching Rust binary from GitHub releases
679686
3. Verify SHA256 checksum
680687
4. Make executable (Unix)
681-
5. First run triggers `karate setup --yes` for JRE/JAR bootstrap
688+
5. First run triggers `karate setup --all` for JRE/JAR bootstrap
682689

683690
**User experience:**
684691
```bash
@@ -713,7 +720,7 @@ class Karate < Formula
713720
end
714721

715722
def post_install
716-
system "#{bin}/karate", "setup", "--yes"
723+
system "#{bin}/karate", "setup", "--all"
717724
end
718725
end
719726
```

docs/tracker.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@
3737
- [x] `karate setup jre` with --force option
3838

3939
### Setup & Bootstrap
40-
- [x] `karate setup` - Full wizard (JRE + JAR)
41-
- [x] `karate setup jre` - JRE only
40+
- [x] `karate setup` - Interactive wizard
41+
- [x] `karate setup --all` - Install JAR + JRE non-interactively
42+
- [x] `karate setup --components jar` - JAR only (use system JRE)
43+
- [x] `karate setup --components jre` - JRE only
4244
- [x] Downloads latest Karate JAR from GitHub releases
4345
- [x] SHA256 checksum support infrastructure (not yet enforced)
44-
- [x] Non-interactive mode (--yes flag)
4546

4647
### Diagnostics
4748
- [x] `karate doctor` - Full system diagnostics
@@ -95,7 +96,7 @@
9596
- [ ] Download new JAR if available
9697
- [ ] Download new JRE if available
9798
- [ ] --version flag for specific version
98-
- [ ] --yes flag for non-interactive
99+
- [ ] --all flag for non-interactive
99100

100101
#### Config Editing
101102
- [ ] `karate config` - Interactive editing
@@ -115,7 +116,7 @@
115116
- [x] Binary download from GitHub releases
116117
- [x] SHA256 verification
117118
- [x] PATH setup instructions
118-
- [x] --yes flag for auto-setup after install
119+
- [x] --all flag for auto-setup after install
119120
- [x] PowerShell script for Windows (install.ps1)
120121
- [x] Same functionality
121122
- [x] Auto-adds to user PATH
@@ -229,7 +230,7 @@ curl -fsSL https://karate.sh/install.sh | sh -s -- --bin-dir /tmp/karate-test
229230
# Test Linux installation in Docker
230231
docker run --rm ubuntu:latest bash -c '
231232
apt-get update && apt-get install -y curl
232-
curl -fsSL https://karate.sh/install.sh | sh -s -- --bin-dir /tmp/bin --yes
233+
curl -fsSL https://karate.sh/install.sh | sh -s -- --bin-dir /tmp/bin --all
233234
/tmp/bin/karate doctor --json
234235
'
235236
```

src/cli.rs

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -50,48 +50,21 @@ pub enum Command {
5050

5151
#[derive(Args, Debug)]
5252
pub struct SetupArgs {
53-
/// Non-interactive mode, accept all defaults
54-
#[arg(short, long)]
55-
pub yes: bool,
53+
/// Install all components (JAR + JRE) non-interactively
54+
#[arg(long, conflicts_with = "components")]
55+
pub all: bool,
5656

57-
#[command(subcommand)]
58-
pub subcommand: Option<SetupSubcommand>,
59-
}
60-
61-
#[derive(Subcommand, Debug)]
62-
pub enum SetupSubcommand {
63-
/// Set up PATH/symlinks only
64-
Path(SetupPathArgs),
65-
66-
/// Install/update JRE only
67-
#[command(disable_version_flag = true)]
68-
Jre(SetupJreArgs),
69-
}
70-
71-
#[derive(Args, Debug)]
72-
pub struct SetupPathArgs {
73-
/// Directory to install the karate binary
74-
#[arg(long)]
75-
pub bin_dir: Option<String>,
76-
77-
/// Modify shell profile to add to PATH (Unix only)
78-
#[arg(long)]
79-
pub modify_shell_profile: bool,
57+
/// Install specific components: jar, jre (comma-separated)
58+
#[arg(long, value_delimiter = ',')]
59+
pub components: Option<Vec<String>>,
8060

81-
/// Add to system PATH (Windows only)
82-
#[arg(long)]
83-
pub add_to_path: bool,
84-
}
61+
/// Force download even if components are already installed
62+
#[arg(long, short)]
63+
pub force: bool,
8564

86-
#[derive(Args, Debug)]
87-
pub struct SetupJreArgs {
8865
/// Specific Java major version to install (e.g., 17, 21)
8966
#[arg(long = "java-version")]
90-
pub version: Option<String>,
91-
92-
/// Force download even if a suitable system JRE is available
93-
#[arg(long, short)]
94-
pub force: bool,
67+
pub java_version: Option<String>,
9568
}
9669

9770
// ============================================================================
@@ -100,9 +73,9 @@ pub struct SetupJreArgs {
10073

10174
#[derive(Args, Debug)]
10275
pub struct UpgradeArgs {
103-
/// Non-interactive mode
104-
#[arg(short, long)]
105-
pub yes: bool,
76+
/// Non-interactive mode (upgrade all components)
77+
#[arg(long)]
78+
pub all: bool,
10679

10780
/// Install specific version instead of latest
10881
#[arg(long)]

0 commit comments

Comments
 (0)