-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_docs.go
130 lines (113 loc) Β· 3.15 KB
/
cmd_docs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package app
import (
"fmt"
"github.com/arrow2nd/nekomata/cli"
"github.com/arrow2nd/nekomata/config"
"github.com/spf13/pflag"
)
func (a *App) newDocsCmd() *cli.Command {
cmd := &cli.Command{
Name: "docs",
Short: "Show documentation",
Hidden: global.isCLI,
Validate: cli.NoArgs(),
}
cmd.AddCommand(a.newDocsKeybindingsCmd())
return cmd
}
func (a *App) newDocsKeybindingsCmd() *cli.Command {
k := global.conf.Pref.Keybindings
global := fmt.Sprintf(
`[Global]
%-20s Quit application
`,
k.Global.GetString(config.ActionQuit),
)
view := fmt.Sprintf(
`[View]
%-20s Select previous tab
%-20s Select next tab
%-20s Close current page
%-20s Redraw screen (window width changes are not reflected)
%-20s Focus the command line
%-20s Show documentation for keybindings
`,
k.View.GetString(config.ActionSelectPrevTab),
k.View.GetString(config.ActionSelectNextTab),
k.View.GetString(config.ActionClosePage),
k.View.GetString(config.ActionRedraw),
k.View.GetString(config.ActionFocusCmdLine),
k.View.GetString(config.ActionShowHelp),
)
page := fmt.Sprintf(
`[Common Page]
%-20s Reload page
`,
k.Page.GetString(config.ActionReloadPage),
)
post := fmt.Sprintf(
`[Post list]
%-20s Scroll up
%-20s Scroll down
%-20s Move cursor up
%-20s Move cursor down
%-20s Move cursor top
%-20s Move cursor bottom
%-20s Reaction
%-20s Unreaction
%-20s Repost
%-20s Unrepost
%-20s Bookmark
%-20s Unbookmark
%-20s New post
%-20s Reply
%-20s Delete
%-20s Open in browser
%-20s Open user timeline page
%-20s Copy link to clipboard
%-20s Follow
%-20s Unfollow
%-20s Mute
%-20s Unmute
%-20s Block
%-20s Unblock
%-20s Open user likes page
`,
k.Posts.GetString(config.ActionScrollUp),
k.Posts.GetString(config.ActionScrollDown),
k.Posts.GetString(config.ActionCursorUp),
k.Posts.GetString(config.ActionCursorDown),
k.Posts.GetString(config.ActionCursorTop),
k.Posts.GetString(config.ActionCursorBottom),
k.Posts.GetString(config.ActionReaction),
k.Posts.GetString(config.ActionUnreaction),
k.Posts.GetString(config.ActionRepost),
k.Posts.GetString(config.ActionUnrepost),
k.Posts.GetString(config.ActionBookmark),
k.Posts.GetString(config.ActionUnbookmark),
k.Posts.GetString(config.ActionPost),
k.Posts.GetString(config.ActionReply),
k.Posts.GetString(config.ActionDelete),
k.Posts.GetString(config.ActionOpenBrowser),
k.Posts.GetString(config.ActionOpenUserPage),
k.Posts.GetString(config.ActionCopyUrl),
k.Posts.GetString(config.ActionFollow),
k.Posts.GetString(config.ActionUnfollow),
k.Posts.GetString(config.ActionMute),
k.Posts.GetString(config.ActionUnmute),
k.Posts.GetString(config.ActionBlock),
k.Posts.GetString(config.ActionUnblock),
k.Posts.GetString(config.ActionOpenUserPage),
)
text := global + view + page + post
return &cli.Command{
Name: "keybindings",
Short: "Documentation for keybindings",
Validate: cli.NoArgs(),
SetFlag: setOpenBackgroundFlag,
Run: func(c *cli.Command, f *pflag.FlagSet) error {
openBackground, _ := f.GetBool("background")
return a.view.AddPage(newDocsPage("Keybindings", text), !openBackground)
},
}
}