File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ pub struct GetToken {
3333 #[ arg( short, long) ]
3434 pub bearer : bool ,
3535
36+ /// Suitable for using directly with HTTPie as header
37+ #[ arg( short = 'H' , long, conflicts_with = "bearer" ) ]
38+ pub header : bool ,
39+
3640 /// Inspect the token
3741 #[ arg( short = 'I' , long, conflicts_with = "bearer" ) ]
3842 pub inspect : bool ,
@@ -84,12 +88,19 @@ impl GetToken {
8488 token. access_token
8589 } ;
8690
87- if self . bearer {
88- println ! ( "Bearer {token}" ) ;
89- } else if self . inspect {
90- inspect ( token) ?;
91- } else {
92- println ! ( "{token}" ) ;
91+ match ( self . bearer , self . header , self . inspect ) {
92+ ( true , _, _) => {
93+ println ! ( "Bearer {token}" ) ;
94+ }
95+ ( _, true , _) => {
96+ println ! ( "Authorization:Bearer {token}" ) ;
97+ }
98+ ( _, _, true ) => {
99+ inspect ( token) ?;
100+ }
101+ _ => {
102+ println ! ( "{token}" ) ;
103+ }
93104 }
94105
95106 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments