You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* rewrite clap opts to use subcommands
* rewrite using match
* handle default destination from clap argument
* cleanup braces
* remove cmd option, force stat default
* handle cd -f together with the regular cd
* subcommand shorthands
* add short status option
* added plain status option
* improve the help
* fix ci test
* refactor location.go_to and add game.visit
* preserve destination side-effects on cd -f
* set quiet/plain as (still unused) globals
* global quiet/plain logging with once_cell
* use quiet/plain in battle
* quiet/plain should be global commands
* more output cleanup
* improve tombstone output
* another tombstone improvement
* no battles at home
* true up readme examples
* update changelog
* use cd -f for ci to prevent error exit code
* add --force to cargo install example
* remove redundant help
* clap help improvements
* format
Copy file name to clipboardExpand all lines: README.md
+15-28Lines changed: 15 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ Just download the binary for your platform (linux/macOS/windows) from the [GitHu
22
22
### Installing with Cargo
23
23
Assuming you have [Rust and Cargo installed](https://doc.rust-lang.org/cargo/getting-started/installation.html#install-rust-and-cargo):
24
24
25
-
$ cargo install --git https://github.com/facundoolano/rpg-cli --branch main
25
+
$ cargo install --git https://github.com/facundoolano/rpg-cli --force --branch main
26
26
27
27
The binary should be available as `rpg-cli` (assuming you have `~/.cargo/bin` in your `$PATH`).
28
28
@@ -39,16 +39,16 @@ The most basic type of integration consists in wrapping rpg-cli in a shell funct
39
39
```sh
40
40
rpg () {
41
41
rpg-cli "$@"
42
-
cd"$(rpg-cli --pwd)"
42
+
cd"$(rpg-cli pwd)"
43
43
}
44
44
```
45
45
46
46
Or, if you want to go all the way and *really* use it in place of `cd`:
47
47
48
48
```sh
49
49
cd () {
50
-
rpg-cli "$@"
51
-
builtincd"$(rpg-cli --pwd)"
50
+
rpg-cli cd"$@"
51
+
builtincd"$(rpg-cli pwd)"
52
52
}
53
53
```
54
54
@@ -65,7 +65,6 @@ This example session assumes a basic `rpg` function as described in the previous
65
65
The first time you run the program, a new hero is created at the user's home directory.
66
66
67
67
~ $ rpg
68
-
69
68
hero[1]@home
70
69
hp:[xxxxxxxxxx] 25/25
71
70
xp:[----------] 0/30
@@ -76,9 +75,8 @@ The first time you run the program, a new hero is created at the user's home dir
76
75
77
76
When running without parameters, as above, the hero status is printed (health points, accumulated experience, etc.). If you pass in a path as parameter, that will instruct the hero to move:
78
77
79
-
~ $ rpg dev/
78
+
~ $ rpg cd dev/
80
79
~/dev $ rpg
81
-
82
80
hero[1]@~/dev
83
81
hp:[xxxxxxxxxx] 25/25
84
82
xp:[----------] 0/30
@@ -90,38 +88,34 @@ When running without parameters, as above, the hero status is printed (health po
90
88
In this case, the hero moved to `~/dev/facundoolano`. Sometimes enemies will appear as you move through the directories,
91
89
and both characters will engage in battle:
92
90
93
-
~/dev $ rpg facundoolano/
94
-
91
+
~/dev $ rpg cd facundoolano/
95
92
snake[1][xxxx]@~/dev/facundoolano
96
-
97
93
snake[1][x---] -12hp
98
94
hero[1][xxxx] dodged!
99
95
snake[1][----] -12hp
100
-
101
-
hero[1][xxxx][xxxx]@~/dev/facundoolano +24xp +75g
96
+
hero[1][xxxx] +24xp +75g
97
+
hero[1][xxxx][xxxx]@~/dev/facundoolano
102
98
103
99
Each character attacks in turn (the frequency being determined by their `speed` stat).
104
100
Whenever you win a fight, your hero gains experience points and eventually raises its level, along with their other stats.
105
101
106
102
When you return to the home directory, the hero's health points are restored:
107
103
108
-
~/dev/facundoolano/rpg-cli $ rpg ~
104
+
~/dev/facundoolano/rpg-cli $ rpg cd ~
109
105
hero[1][xxxx][xxxx]@home +20hp
110
106
111
107
Also at the home directory, you can buy items and equipment:
112
108
113
-
~ $ rpg --shop
114
-
109
+
~ $ rpg buy
115
110
sword[1] 500g
116
111
shield[1] 500g
117
112
potion[1] 200g
118
113
escape 1000g
119
114
120
115
funds: 275g
121
116
122
-
~ $ rpg --shop potion
117
+
~ $ rpg buy potion
123
118
~ $ rpg
124
-
125
119
hero[3]@home
126
120
hp:[xxxxxxxxxx] 37/37
127
121
xp:[xx--------] 19/155
@@ -130,29 +124,22 @@ Also at the home directory, you can buy items and equipment:
130
124
item:{potion[1]x1}
131
125
75g
132
126
133
-
The shortcut `rpg -s p` would also work above.
127
+
The shortcut `rpg b p` would also work above.
134
128
135
129
The further from home you move the hero, the tougher the enemies will get. If you go to far or too long without restoring your health your hero is likely to die in battle, causing the game to restart.
Copy file name to clipboardExpand all lines: shell/README.md
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ you need to write a function so the working directory is changed to match that o
13
13
```sh
14
14
rpg () {
15
15
rpg-cli "$@"
16
-
cd"$(rpg-cli --pwd)"
16
+
cd"$(rpg-cli pwd)"
17
17
}
18
18
```
19
19
@@ -24,7 +24,7 @@ If you use fish shell, update `~/.config/fish/config.fish` instead:
24
24
```fish
25
25
function rpg
26
26
rpg-cli $argv
27
-
cd (rpg-cli --pwd)
27
+
cd (rpg-cli pwd)
28
28
end
29
29
```
30
30
@@ -34,18 +34,20 @@ If you like having enemies popping up while using `cd`, you can override that in
34
34
35
35
```sh
36
36
cd () {
37
-
rpg-cli "$@"
38
-
builtincd"$(rpg-cli --pwd)"
37
+
rpg-cli cd"$@"
38
+
builtincd"$(rpg-cli pwd)"
39
39
}
40
40
```
41
41
42
42
## Custom integration commands
43
43
44
44
To better adapt for different usage patterns, finer-grained commands are provided:
45
45
46
-
*`rpg-cli --mv <path>` will set the hero's location to `<path>` without initiating battles.
47
-
*`rpg-cli --pwd` will print the hero's current location.
48
-
*`rpg-cli --battle` will initiate a battle with a probability that changes based on the distance from home. If the battle is lost the exit code of the program will be non-negative.
46
+
*`rpg-cli cd --force <path>` will set the hero's location to `<path>` without initiating battles.
47
+
*`rpg-cli pwd` will print the hero's current location.
48
+
*`rpg-cli battle` will initiate a battle with a probability that changes based on the distance from home. If the battle is lost the exit code of the program will be non-negative.
49
+
*`rpg-cli stat --quiet` will return hero stats in a succinct format.
50
+
*`rpg-cli stat --plain` will return hero stats as tab separated fields, to facilitate parsing (e.g. to integrate to the prompt).
49
51
50
52
## Prevent intermediate battles
51
53
@@ -60,8 +62,8 @@ A better alternative for this usage pattern is enabled by the other integration
60
62
```sh
61
63
cd () {
62
64
builtincd"$@"
63
-
rpg-cli --mv.
64
-
rpg-cli --battle
65
+
rpg-cli cd -f.
66
+
rpg-cli battle
65
67
}
66
68
```
67
69
@@ -70,7 +72,7 @@ cd () {
70
72
Another way to use rpg-cli is to initiate battles when attempting to execute file-modifying operations. Only when the battle is won the operation is allowed:
71
73
72
74
```sh
73
-
alias rpg-battle="rpg-cli --mv . && rpg-cli --battle"
75
+
alias rpg-battle="rpg-cli cd -f . && rpg-cli battle"
0 commit comments