Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add confirm prompt #1834

Merged
merged 36 commits into from
Jan 13, 2024
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ec0794c
add optional boxed string for prompt text
CramBL Jan 10, 2024
8b28f7b
add test with confirmation prompt
CramBL Jan 10, 2024
3c266d8
implement confirm prompt
CramBL Jan 10, 2024
a3fd212
remove redundant test
CramBL Jan 11, 2024
4a11619
Use Option<String> instead of boxed string
CramBL Jan 11, 2024
d28ac60
completely override prompt if user defines a prompt
CramBL Jan 11, 2024
fe22811
describe custom confirmation prompt
CramBL Jan 11, 2024
04b6b7d
address comments about confirm prompt documentation
CramBL Jan 12, 2024
d03a45a
add compile error variant for attribute args
CramBL Jan 12, 2024
bc7636e
add expect_args and with_arguments for Attribute enum
CramBL Jan 12, 2024
233b177
revise parsing of attribute args
CramBL Jan 12, 2024
12e63a6
also revert alignment of settings table
CramBL Jan 12, 2024
3c90d6a
make more generic
CramBL Jan 12, 2024
d1c2ed7
add error message to AttributeArgumentCountMismatch compileerrorkid
CramBL Jan 12, 2024
05faf55
remove duplicate assertions
CramBL Jan 12, 2024
dec8ed7
use hacky range_contains of that treats half-open range as open range
CramBL Jan 12, 2024
2734e93
fix broken DisplayRange and add assertions for clarifying
CramBL Jan 12, 2024
6545e54
add confirm test with too many args
CramBL Jan 12, 2024
145bc89
Merge branch 'master' into add-confirm-prompt
CramBL Jan 12, 2024
bc1f5f1
update test
CramBL Jan 12, 2024
4c1bf1c
implement display for RangeInclusive
CramBL Jan 12, 2024
7589a2b
use RangeInclusive instead of Range
CramBL Jan 12, 2024
b86ded7
accept comma-separated arguments
CramBL Jan 12, 2024
5987265
update test
CramBL Jan 12, 2024
fcea9a6
replace unreleased with master
CramBL Jan 12, 2024
2ee15f0
revert to just support a single recipe attribute argument
CramBL Jan 12, 2024
b528c0d
Add to grammar and tweak readme
casey Jan 13, 2024
d6caa19
Tweak
casey Jan 13, 2024
50d47c7
Tweak
casey Jan 13, 2024
e8387bc
Tweak
casey Jan 13, 2024
41c8071
Tweak
casey Jan 13, 2024
76ca7bb
Tweak
casey Jan 13, 2024
bc82faf
Tweak
casey Jan 13, 2024
b8b3317
Tweak
casey Jan 13, 2024
cb43e0f
Tweak
casey Jan 13, 2024
1c7585c
Tweak
casey Jan 13, 2024
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
59 changes: 35 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -755,20 +755,20 @@ foo:

#### Table of Settings

| Name | Value | Default | Description |
| -----| ------| ------- |-------------|
| `allow-duplicate-recipes` | boolean | `false` | Allow recipes appearing later in a `justfile` to override earlier recipes with the same name. |
| `dotenv-filename` | string | - | Load a `.env` file with a custom name, if present. |
| `dotenv-load` | boolean | `false` | Load a `.env` file, if present. |
| `dotenv-path` | string | - | Load a `.env` file from a custom path, if present. Overrides `dotenv-filename`. |
| `export` | boolean | `false` | Export all variables as environment variables. |
| `fallback` | boolean | `false` | Search `justfile` in parent directory if the first recipe on the command line is not found. |
| `ignore-comments` | boolean | `false` | Ignore recipe lines beginning with `#`. |
| `positional-arguments` | boolean | `false` | Pass positional arguments. |
| `shell` | `[COMMAND, ARGS…]` | - | Set the command used to invoke recipes and evaluate backticks. |
| `tempdir` | string | - | Create temporary directories in `tempdir` instead of the system default temporary directory. |
| `windows-powershell` | boolean | `false` | Use PowerShell on Windows as default shell. (Deprecated. Use `windows-shell` instead. |
| `windows-shell` | `[COMMAND, ARGS…]` | - | Set the command used to invoke recipes and evaluate backticks. |
| Name | Value | Default | Description |
CramBL marked this conversation as resolved.
Show resolved Hide resolved
| ------------------------- | ------------------ | ------- | --------------------------------------------------------------------------------------------- |
| `allow-duplicate-recipes` | boolean | `false` | Allow recipes appearing later in a `justfile` to override earlier recipes with the same name. |
| `dotenv-filename` | string | - | Load a `.env` file with a custom name, if present. |
| `dotenv-load` | boolean | `false` | Load a `.env` file, if present. |
| `dotenv-path` | string | - | Load a `.env` file from a custom path, if present. Overrides `dotenv-filename`. |
| `export` | boolean | `false` | Export all variables as environment variables. |
| `fallback` | boolean | `false` | Search `justfile` in parent directory if the first recipe on the command line is not found. |
| `ignore-comments` | boolean | `false` | Ignore recipe lines beginning with `#`. |
| `positional-arguments` | boolean | `false` | Pass positional arguments. |
| `shell` | `[COMMAND, ARGS…]` | - | Set the command used to invoke recipes and evaluate backticks. |
| `tempdir` | string | - | Create temporary directories in `tempdir` instead of the system default temporary directory. |
| `windows-powershell` | boolean | `false` | Use PowerShell on Windows as default shell. (Deprecated. Use `windows-shell` instead. |
| `windows-shell` | `[COMMAND, ARGS…]` | - | Set the command used to invoke recipes and evaluate backticks. |

Boolean settings can be written as:

Expand Down Expand Up @@ -1419,16 +1419,17 @@ which will halt execution.

Recipes may be annotated with attributes that change their behavior.

| Name | Description |
| -----| ------------|
| `[confirm]`<sup>1.17.0</sup> | Require confirmation prior to executing recipe. |
| `[linux]`<sup>1.8.0</sup> | Enable recipe on Linux. |
| `[macos]`<sup>1.8.0</sup> | Enable recipe on MacOS. |
| `[no-cd]`<sup>1.9.0</sup> | Don't change directory before executing recipe. |
| `[no-exit-message]`<sup>1.7.0</sup> | Don't print an error message if recipe fails. |
| `[private]`<sup>1.10.0</sup> | See [Private Recipes](#private-recipes). |
| `[unix]`<sup>1.8.0</sup> | Enable recipe on Unixes. (Includes MacOS). |
| `[windows]`<sup>1.8.0</sup> | Enable recipe on Windows. |
| Name | Description |
| ------------------------------------------------- | ----------------------------------------------- |
| `[confirm]`<sup>1.17.0</sup> | Require confirmation prior to executing recipe. |
| `[confirm("custom prompt")]`<sup>unreleased</sup> | Same as above but with a user-defined prompt |
| `[linux]`<sup>1.8.0</sup> | Enable recipe on Linux. |
| `[macos]`<sup>1.8.0</sup> | Enable recipe on MacOS. |
| `[no-cd]`<sup>1.9.0</sup> | Don't change directory before executing recipe. |
| `[no-exit-message]`<sup>1.7.0</sup> | Don't print an error message if recipe fails. |
| `[private]`<sup>1.10.0</sup> | See [Private Recipes](#private-recipes). |
| `[unix]`<sup>1.8.0</sup> | Enable recipe on Unixes. (Includes MacOS). |
| `[windows]`<sup>1.8.0</sup> | Enable recipe on Windows. |

A recipe can have multiple attributes, either on multiple lines:

Expand Down Expand Up @@ -1509,6 +1510,16 @@ delete all:
rm -rf *
```

#### Customize recipe confirmation prompt <sup>unreleased</sup>

The default prompt: ``Run recipe `foo`?`` can be overwritten with the `[confirm("custom prompt")]` syntax.
CramBL marked this conversation as resolved.
Show resolved Hide resolved

```just
[confirm("Are you sure you want to delete all? It is not reversible")]
delete all:
CramBL marked this conversation as resolved.
Show resolved Hide resolved
rm -rf *
```

### Command Evaluation Using Backticks

Backticks can be used to store the result of commands:
Expand Down