Skip to content

Commit 95f3a26

Browse files
authored
Organize command groupings in hishtory help + unhide the install command (ddworken#278)
1 parent 2ff52a8 commit 95f3a26

5 files changed

Lines changed: 25 additions & 17 deletions

File tree

‎client/cmd/export.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ import (
1515
)
1616

1717
var exportJsonCmd = &cobra.Command{
18-
Use: "export-json",
19-
Short: "Export history entries formatted in JSON lines format (as accepted by hishtory import-json, and easily parsable by other tools)",
18+
Use: "export-json",
19+
Short: "Export history entries formatted in JSON lines format (as accepted by hishtory import-json, and easily parsable by other tools)",
20+
GroupID: GROUP_ID_MANAGEMENT,
2021
Run: func(cmd *cobra.Command, args []string) {
2122
ctx := hctx.MakeContext()
2223
err := exportToJson(ctx, os.Stdout)

‎client/cmd/import.go‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ import (
1717
)
1818

1919
var importCmd = &cobra.Command{
20-
Use: "import",
21-
Hidden: true,
22-
Short: "Re-import history entries from your existing shell history",
23-
Long: "Note that you may also pipe commands to be imported in via stdin. For example `history | hishtory import`.",
20+
Use: "import",
21+
GroupID: GROUP_ID_MANAGEMENT,
22+
Hidden: true,
23+
Short: "Re-import history entries from your existing shell history",
24+
Long: "Note that you may also pipe commands to be imported in via stdin. For example `history | hishtory import`.",
2425
Run: func(cmd *cobra.Command, args []string) {
2526
ctx := hctx.MakeContext()
2627
numImported, err := lib.ImportHistory(ctx, true, true)
@@ -32,8 +33,9 @@ var importCmd = &cobra.Command{
3233
}
3334

3435
var importJsonCmd = &cobra.Command{
35-
Use: "import-json",
36-
Short: "Import history entries formatted in JSON lines format into hiSHtory",
36+
Use: "import-json",
37+
GroupID: GROUP_ID_MANAGEMENT,
38+
Short: "Import history entries formatted in JSON lines format into hiSHtory",
3739
Long: "Data is read from stdin. For example: `cat data.txt | hishtory import-json`.\n\nExample JSON format:\n\n```\n" +
3840
"{\"command\":\"echo foo\"}\n" +
3941
"{\"command\":\"echo bar\", \"current_working_directory\": \"/tmp/\"}\n" +

‎client/cmd/install.go‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ var (
3636
currentlyInstalledVersion *string
3737
)
3838

39+
var GROUP_ID_INSTALL string = "group_id_install"
40+
3941
var installCmd = &cobra.Command{
40-
Use: "install",
41-
Hidden: true,
42-
Short: "Copy this binary to ~/.hishtory/ and configure your shell to use it for recording your shell history",
43-
Args: cobra.MaximumNArgs(1),
42+
Use: "install",
43+
Short: "Copy this binary to ~/.hishtory/ and configure your shell to use it for recording your shell history",
44+
GroupID: GROUP_ID_INSTALL,
45+
Args: cobra.MaximumNArgs(1),
4446
Run: func(cmd *cobra.Command, args []string) {
4547
secretKey := ""
4648
if len(args) > 0 {
@@ -72,7 +74,7 @@ var installCmd = &cobra.Command{
7274
var initCmd = &cobra.Command{
7375
Use: "init",
7476
Short: "Re-initialize hiSHtory with a specified secret key",
75-
GroupID: GROUP_ID_CONFIG,
77+
GroupID: GROUP_ID_INSTALL,
7678
Args: cobra.MaximumNArgs(1),
7779
Run: func(cmd *cobra.Command, args []string) {
7880
db, err := hctx.OpenLocalSqliteDb()
@@ -107,8 +109,9 @@ var initCmd = &cobra.Command{
107109
}
108110

109111
var uninstallCmd = &cobra.Command{
110-
Use: "uninstall",
111-
Short: "Completely uninstall hiSHtory and remove your shell history",
112+
Use: "uninstall",
113+
Short: "Completely uninstall hiSHtory and remove your shell history",
114+
GroupID: GROUP_ID_INSTALL,
112115
Run: func(cmd *cobra.Command, args []string) {
113116
ctx := hctx.MakeContext()
114117
fmt.Printf("Are you sure you want to uninstall hiSHtory and delete all locally saved history data [y/N]")

‎client/cmd/root.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ func init() {
3030
rootCmd.AddGroup(&cobra.Group{ID: GROUP_ID_QUERYING, Title: "History Searching"})
3131
rootCmd.AddGroup(&cobra.Group{ID: GROUP_ID_MANAGEMENT, Title: "History Management"})
3232
rootCmd.AddGroup(&cobra.Group{ID: GROUP_ID_CONFIG, Title: "Configuration"})
33+
rootCmd.AddGroup(&cobra.Group{ID: GROUP_ID_INSTALL, Title: "Installation"})
3334
rootCmd.Version = "v0." + lib.Version
3435
}

‎client/cmd/update.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ import (
2222
)
2323

2424
var updateCmd = &cobra.Command{
25-
Use: "update",
26-
Short: "Securely update hishtory to the latest version",
25+
Use: "update",
26+
GroupID: GROUP_ID_INSTALL,
27+
Short: "Securely update hishtory to the latest version",
2728
Run: func(cmd *cobra.Command, args []string) {
2829
lib.CheckFatalError(update(hctx.MakeContext()))
2930
},

0 commit comments

Comments
 (0)