File tree Expand file tree Collapse file tree 4 files changed +43
-9
lines changed Expand file tree Collapse file tree 4 files changed +43
-9
lines changed Original file line number Diff line number Diff line change 2
2
3
3
[ ![ Unit Test] ( https://github.com/open-jike/jike-cli/actions/workflows/unit-test.yml/badge.svg )] ( https://github.com/open-jike/jike-cli/actions/workflows/unit-test.yml )
4
4
5
- ## Install
5
+ ## Installation
6
6
7
7
``` bash
8
- npm i jike-cli
8
+ $ npm i -g jike-cli
9
9
```
10
10
11
+ ## Usage
12
+
13
+ ``` bash
14
+ $ jike-cli --help
15
+ ```
16
+
17
+ ### User
18
+
19
+ ``` bash
20
+ $ jike-cli user login # 登录
21
+ $ jike-cli user logout # 退出
22
+ $ jike-cli user renew # 刷新 token
23
+ $ jike-cli user profile # 查看用户主页
24
+ $ jike-cli user view # 在浏览器中打开网页版
25
+ ```
26
+
27
+ For more details, please use ` help ` command.
28
+
11
29
## License
12
30
13
31
[ AGPL-3.0] ( ./LICENSE ) License © 2022-PRESENT [ 三咲智子] ( https://github.com/sxzz )
Original file line number Diff line number Diff line change @@ -7,7 +7,18 @@ import { renew } from './renew'
7
7
import { view } from './view'
8
8
9
9
export const user = createCommand ( 'user' )
10
- . description ( 'manager users' )
10
+ . description ( 'user-related operations' )
11
+ . addHelpText (
12
+ 'after' ,
13
+ `
14
+
15
+ Example call:
16
+ $ jike-cli user login
17
+ $ jike-cli user profile 82D23B32-CF36-4C59-AD6F-D05E3552CBF3
18
+ $ jike-cli user renew
19
+ $ jike-cli user view 82D23B32-CF36-4C59-AD6F-D05E3552CBF3
20
+ `
21
+ )
11
22
. usage ( '<command> [flags]' )
12
23
. addCommand ( renew )
13
24
. addCommand ( login )
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ export interface ProfileOptions {
17
17
}
18
18
19
19
export const profile = createCommand ( 'profile' )
20
- . argument ( '[username]' )
20
+ . argument ( '[username]' , 'the username of user' )
21
21
. description ( 'query user profile' )
22
22
. option ( '-r, --raw' , 'output raw data' )
23
23
. option ( '-p, --pretty' , 'pretty raw data' )
Original file line number Diff line number Diff line change @@ -3,14 +3,19 @@ import { createCommand } from 'commander'
3
3
import open from 'open'
4
4
import { createClient , filterUsers } from '../../utils/user'
5
5
6
+ interface ViewOptions {
7
+ username : string
8
+ mobile : boolean
9
+ }
10
+
6
11
export const view = createCommand ( 'view' )
7
- . description ( 'query user view ')
8
- . option ( '-U, --username <username>' , 'the username of user ')
12
+ . argument ( '[username]' , 'the username of user ')
13
+ . description ( 'open user profile in browser ')
9
14
. option ( '-m, --mobile' , 'view page for mobile phone' )
10
- . action ( ( ) => viewUser ( ) )
15
+ . action ( ( username ?: string ) => viewUser ( username ) )
11
16
12
- export const viewUser = async ( ) => {
13
- let { username , mobile } = view . opts < { username : string ; mobile : boolean } > ( )
17
+ export const viewUser = async ( username ?: string ) => {
18
+ const { mobile } = view . opts < Omit < ViewOptions , ' username' > > ( )
14
19
if ( ! username ) {
15
20
const [ user ] = filterUsers ( )
16
21
const client = createClient ( user )
You can’t perform that action at this time.
0 commit comments