Skip to content

Commit d12faa5

Browse files
committed
Update documents
1 parent 54cc60c commit d12faa5

File tree

5 files changed

+48
-7
lines changed

5 files changed

+48
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ For detailed information about the config file format, see [Config File Format](
104104

105105
### User command
106106

107-
The User command view allows you to display the output (stdout) of your custom external commands.
108-
This allows you to do things like view commit diffs using your favorite tools.
107+
The User command feature allows you to execute custom external commands.
108+
You can display the output of commands like `git diff` in a dedicated view, or execute commands like branch deletion in the background.
109109

110110
For details on how to set commands, see [User Command](https://lusingander.github.io/serie/features/user-command.html).
111111

config.schema.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,26 @@
9898
"type": "string",
9999
"description": "The name of the command to be displayed."
100100
},
101+
"type": {
102+
"type": "string",
103+
"description": "The type of user command.",
104+
"enum": [
105+
"inline",
106+
"silent"
107+
],
108+
"default": "inline"
109+
},
101110
"commands": {
102111
"type": "array",
103112
"description": "The command and its arguments to execute.",
104113
"items": {
105114
"type": "string"
106115
}
116+
},
117+
"refresh": {
118+
"type": "boolean",
119+
"description": "Whether to reload the repository and refresh the display after executing the command. Only available for 'silent' commands.",
120+
"default": false
107121
}
108122
},
109123
"required": [

docs/src/configurations/config-file-format.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,25 @@ Whether to enable fuzzy matching by default.
182182

183183
### `core.user_command.commands_{n}`
184184

185-
The command definition for generating the content displayed in the user command view.
185+
The command definition for executing external commands.
186186

187187
Multiple commands can be specified in the format `commands_{n}`.
188188
For details about user command, see the separate [User command](../features/user-command.md) section.
189189

190190
- type: `object`
191191
- fields:
192192
- `name`: `string` - The name of the user command.
193+
- `type`: `string` (enum) - The type of user command.
194+
- default: `inline`
195+
- possible values:
196+
- `inline`: Display the output of the command in the user command view.
197+
- `silent`: Execute the command in the background without opening a view.
193198
- `commands`: `array of strings` - The command and its arguments.
199+
- `refresh`: `boolean` - Whether to reload the repository and refresh the display after executing the command. Only available for `silent` commands.
200+
- default: `false`
194201
- examples:
195202
- `commands_1 = { name = "git diff", commands = ["git", "--no-pager", "diff", "--color=always", "{{first_parent_hash}}", "{{target_hash}}"]}`
203+
- `commands_2 = { name = "delete branch", type = "silent", commands = ["git", "branch", "-D", "{{branches}}"], refresh = true }`
196204

197205
### `core.user_command.tab_width`
198206

docs/src/features/user-command.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
# User Command
22

3-
The User command view allows you to display the output (stdout) of your custom external commands.
4-
This allows you to do things like view commit diffs using your favorite tools.
3+
The User command feature allows you to execute custom external commands.
4+
There are two types of user commands: `inline` and `silent`.
5+
6+
- `inline` (default)
7+
- Displays the output (stdout) of the command in a dedicated view within the TUI.
8+
- This allows you to do things like view commit diffs using your favorite tools.
9+
- `silent`
10+
- Executes the command in the background without opening a view.
11+
- This is useful for operations that don't require checking output, such as deleting branches or adding tags.
512

613
To define a user command, you need to configure the following two settings:
7-
- Keybinding definition. Specify the key to display each user command.
14+
- Keybinding definition. Specify the key to execute each user command.
815
- Config: `keybind.user_command_{n}`
916
- Command definition. Specify the actual command you want to execute.
1017
- Config: `core.user_command.commands_{n}`
@@ -15,12 +22,24 @@ To define a user command, you need to configure the following two settings:
1522
[keybind]
1623
user_command_1 = ["d"]
1724
user_command_2 = ["shift-d"]
25+
user_command_3 = ["b"]
1826

1927
[core.user_command]
28+
# Inline command (default)
2029
commands_1 = { "name" = "git diff", commands = ["git", "--no-pager", "diff", "--color=always", "{{first_parent_hash}}", "{{target_hash}}"] }
30+
# Inline command with custom area size
2131
commands_2 = { "name" = "xxx", commands = ["xxx", "{{first_parent_hash}}", "{{target_hash}}", "--width", "{{area_width}}", "--height", "{{area_height}}"] }
32+
# Silent command with refresh
33+
commands_3 = { "name" = "delete branch", type = "silent", commands = ["git", "branch", "-D", "{{branches}}"], refresh = true }
2234
```
2335

36+
## Refresh
37+
38+
For `silent` commands, you can set `refresh = true` to automatically reload the repository and refresh the display (e.g., commit list) after the command is executed.
39+
This is useful when the command modifies the repository state.
40+
41+
Note that `refresh = true` cannot be used with `inline` commands.
42+
2443
## Variables
2544

2645
The following variables can be used in command definitions.

src/view/help.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ fn build_lines(
221221
.user_command
222222
.commands
223223
.get(&n.to_string())
224-
.map(|c| format!("Toggle user command {} - {}", n, c.name))
224+
.map(|c| format!("Execute user command {} - {}", n, c.name))
225225
.map(|desc| (vec![UserEvent::UserCommand(n)], desc))
226226
})
227227
.collect::<Vec<_>>();

0 commit comments

Comments
 (0)