@@ -74,7 +74,10 @@ fn run() -> Result<()> {
7474 let command = cli. command . unwrap_or ( Command :: Show ( cli:: ShowArgs { } ) ) ;
7575
7676 // Handle commands that don't need jj/gh state early.
77- if let Command :: Util ( cli:: UtilArgs { command : cli:: UtilCommand :: InstallAliases ( args) } ) = & command {
77+ if let Command :: Util ( cli:: UtilArgs {
78+ command : cli:: UtilCommand :: InstallAliases ( args) ,
79+ } ) = & command
80+ {
7881 return install_aliases ( args. repo ) ;
7982 }
8083
@@ -95,7 +98,10 @@ fn run() -> Result<()> {
9598 } ) ;
9699
97100 // Handle util commands that need input data.
98- if let Command :: Util ( cli:: UtilArgs { command : cli:: UtilCommand :: Dump } ) = & command {
101+ if let Command :: Util ( cli:: UtilArgs {
102+ command : cli:: UtilCommand :: Dump ,
103+ } ) = & command
104+ {
99105 serde_json:: to_writer ( std:: io:: stdout ( ) , input) ?;
100106 println ! ( ) ;
101107 return Ok ( ( ) ) ;
@@ -166,22 +172,6 @@ fn install_aliases(repo: bool) -> Result<()> {
166172
167173 let scope = if repo { "--repo" } else { "--user" } ;
168174
169- let aliases = [
170- ( "revset-aliases.\" pr(n)\" " , r#"description(regex:"PR: #" ++ n)"# ) ,
171- ( "revset-aliases.\" pr_root(n)\" " , r#"roots(pr(n))"# ) ,
172- ] ;
173-
174- for ( key, value) in & aliases {
175- let output = Cmd :: new ( "jj" )
176- . args ( [ "config" , "set" , scope, key, value] )
177- . output ( )
178- . context ( "Failed to run `jj config set`" ) ?;
179- if !output. status . success ( ) {
180- let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
181- anyhow:: bail!( "jj config set failed for {key}: {stderr}" ) ;
182- }
183- }
184-
185175 // Install `jj pr` subcommand alias.
186176 let output = Cmd :: new ( "jj" )
187177 . args ( [
@@ -198,14 +188,30 @@ fn install_aliases(repo: bool) -> Result<()> {
198188 anyhow:: bail!( "jj config set failed for aliases.pr: {stderr}" ) ;
199189 }
200190
191+ let aliases = [
192+ ( "revset-aliases.\" pr(n)\" " , r#"description(regex:"PR: #" ++ n)"# ) ,
193+ ( "revset-aliases.\" pr_root(n)\" " , r#"roots(pr(n))"# ) ,
194+ ] ;
195+
196+ for ( key, value) in & aliases {
197+ let output = Cmd :: new ( "jj" )
198+ . args ( [ "config" , "set" , scope, key, value] )
199+ . output ( )
200+ . context ( "Failed to run `jj config set`" ) ?;
201+ if !output. status . success ( ) {
202+ let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
203+ anyhow:: bail!( "jj config set failed for {key}: {stderr}" ) ;
204+ }
205+ }
206+
201207 eprintln ! ( "Installed to {scope} config:" ) ;
208+ eprintln ! ( " command alias: jj pr — runs jj-pr" ) ;
202209 eprintln ! ( " revset alias: pr(n) — all commits in PR #n" ) ;
203210 eprintln ! ( " revset alias: pr_root(n) — root commit(s) of PR #n" ) ;
204- eprintln ! ( " command alias: jj pr — runs jj-pr" ) ;
205211 eprintln ! ( ) ;
206212 eprintln ! ( "Usage:" ) ;
213+ eprintln ! ( " jj pr show" ) ;
207214 eprintln ! ( " jj log -r 'pr(\" 1234\" )'" ) ;
208215 eprintln ! ( " jj rebase -s 'pr_root(\" 1234\" )' -d main" ) ;
209- eprintln ! ( " jj pr show" ) ;
210216 Ok ( ( ) )
211217}
0 commit comments