just playing with tangled
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cli `init`: make `jj init` an alias that prints an error

The main goal here is so that a completely new user that types in `jj
init` gets a pointer to the correct command needed to try out `jj`.

+40
+2
CHANGELOG.md
··· 91 91 * `jj git fetch` now supports [string pattern syntax](docs/revsets.md#string-patterns) 92 92 on `--remote` option and `git.fetch` configuration. 93 93 94 + * The `jj init` stub that prints an error is now an alias that can be overridden. 95 + 94 96 ### Fixed bugs 95 97 96 98 * `jj status` now shows untracked files under untracked directories.
+8
cli/src/config/misc.toml
··· 5 5 b = ["bookmark"] 6 6 ci = ["commit"] 7 7 unamend = ["unsquash"] 8 + init = [ 9 + "util", 10 + "error", 11 + "`jj init` is not defined by default. Perhaps you meant `jj git init`?", 12 + "--hint", 13 + """You can configure `aliases.init=["git", "init"]` if you always use the Git backend.""", 14 + "--" 15 + ] 8 16 9 17 [diff.color-words] 10 18 max-inline-alternation = 3
+30
cli/tests/test_util_command.rs
··· 180 180 [exit status: 1] 181 181 "); 182 182 } 183 + 184 + #[test] 185 + fn test_erroring_aliases() { 186 + let test_env = TestEnvironment::default(); 187 + let output = test_env.run_jj_in(".", ["init", "repo"]); 188 + insta::assert_snapshot!(output, @r#" 189 + ------- stderr ------- 190 + Error: `jj init` is not defined by default. Perhaps you meant `jj git init`? 191 + Hint: You can configure `aliases.init=["git", "init"]` if you always use the Git backend. 192 + [EOF] 193 + [exit status: 1] 194 + "#); 195 + let output = test_env.run_jj_in(".", ["init", "--help"]); 196 + insta::assert_snapshot!(output, @r#" 197 + ------- stderr ------- 198 + Error: `jj init` is not defined by default. Perhaps you meant `jj git init`? 199 + Hint: You can configure `aliases.init=["git", "init"]` if you always use the Git backend. 200 + [EOF] 201 + [exit status: 1] 202 + "#); 203 + 204 + // Test that `init` can be overridden as an alias. (We use `jj config get` 205 + // as a command with a predictable output) 206 + test_env.add_config(r#"aliases.init=["config", "get", "user.name"]"#); 207 + let output = test_env.run_jj_in(".", ["init"]); 208 + insta::assert_snapshot!(output, @r" 209 + Test User 210 + [EOF] 211 + "); 212 + }