mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-19 19:37:59 +02:00
Better organize the cobra generated help page
This commit is contained in:
parent
ecdd22dcdd
commit
27bbe97cb2
@ -7,8 +7,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var configAddCmd = &cobra.Command{
|
var configAddCmd = &cobra.Command{
|
||||||
Use: "config-add",
|
Use: "config-add",
|
||||||
Short: "Add a config option",
|
Short: "Add a config option",
|
||||||
|
GroupID: GROUP_ID_CONFIG,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cmd.Help()
|
cmd.Help()
|
||||||
},
|
},
|
||||||
|
@ -9,8 +9,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var configDeleteCmd = &cobra.Command{
|
var configDeleteCmd = &cobra.Command{
|
||||||
Use: "config-delete",
|
Use: "config-delete",
|
||||||
Short: "Delete a config option",
|
Short: "Delete a config option",
|
||||||
|
GroupID: GROUP_ID_CONFIG,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cmd.Help()
|
cmd.Help()
|
||||||
},
|
},
|
||||||
|
@ -8,9 +8,12 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var GROUP_ID_CONFIG string = "group_id_config"
|
||||||
|
|
||||||
var configGetCmd = &cobra.Command{
|
var configGetCmd = &cobra.Command{
|
||||||
Use: "config-get",
|
Use: "config-get",
|
||||||
Short: "Get the value of a config option",
|
Short: "Get the value of a config option",
|
||||||
|
GroupID: GROUP_ID_CONFIG,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cmd.Help()
|
cmd.Help()
|
||||||
},
|
},
|
||||||
|
@ -9,8 +9,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var configSetCmd = &cobra.Command{
|
var configSetCmd = &cobra.Command{
|
||||||
Use: "config-set",
|
Use: "config-set",
|
||||||
Short: "Set the value of a config option",
|
Short: "Set the value of a config option",
|
||||||
|
GroupID: GROUP_ID_CONFIG,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cmd.Help()
|
cmd.Help()
|
||||||
},
|
},
|
||||||
|
@ -7,8 +7,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var enableCmd = &cobra.Command{
|
var enableCmd = &cobra.Command{
|
||||||
Use: "enable",
|
Use: "enable",
|
||||||
Short: "Enable hiSHtory recording",
|
Short: "Enable hiSHtory recording",
|
||||||
|
GroupID: GROUP_ID_CONFIG,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
ctx := hctx.MakeContext()
|
ctx := hctx.MakeContext()
|
||||||
lib.CheckFatalError(lib.Enable(ctx))
|
lib.CheckFatalError(lib.Enable(ctx))
|
||||||
@ -16,8 +17,9 @@ var enableCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var disableCmd = &cobra.Command{
|
var disableCmd = &cobra.Command{
|
||||||
Use: "disable",
|
Use: "disable",
|
||||||
Short: "Disable hiSHtory recording",
|
Short: "Disable hiSHtory recording",
|
||||||
|
GroupID: GROUP_ID_CONFIG,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
ctx := hctx.MakeContext()
|
ctx := hctx.MakeContext()
|
||||||
lib.CheckFatalError(lib.Disable(ctx))
|
lib.CheckFatalError(lib.Disable(ctx))
|
||||||
|
@ -9,9 +9,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var importCmd = &cobra.Command{
|
var importCmd = &cobra.Command{
|
||||||
Use: "import",
|
Use: "import",
|
||||||
Short: "Re-import history entries from your existing shell history",
|
Hidden: true,
|
||||||
Long: "Note that you must pipe commands to be imported in via stdin. For example `history | hishtory import`.",
|
Short: "Re-import history entries from your existing shell history",
|
||||||
|
Long: "Note that you must pipe commands to be imported in via stdin. For example `history | hishtory import`.",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
ctx := hctx.MakeContext()
|
ctx := hctx.MakeContext()
|
||||||
numImported, err := lib.ImportHistory(ctx, true, true)
|
numImported, err := lib.ImportHistory(ctx, true, true)
|
||||||
|
@ -14,9 +14,10 @@ import (
|
|||||||
var offline *bool
|
var offline *bool
|
||||||
|
|
||||||
var initCmd = &cobra.Command{
|
var initCmd = &cobra.Command{
|
||||||
Use: "init",
|
Use: "init",
|
||||||
Short: "Re-initialize hiSHtory with a specified secret key",
|
Short: "Re-initialize hiSHtory with a specified secret key",
|
||||||
Args: cobra.MaximumNArgs(1),
|
GroupID: GROUP_ID_CONFIG,
|
||||||
|
Args: cobra.MaximumNArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cmd.Flag("offline").Value.String()
|
cmd.Flag("offline").Value.String()
|
||||||
db, err := hctx.OpenLocalSqliteDb()
|
db, err := hctx.OpenLocalSqliteDb()
|
||||||
|
@ -10,8 +10,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var installCmd = &cobra.Command{
|
var installCmd = &cobra.Command{
|
||||||
Use: "install",
|
Use: "install",
|
||||||
Short: "Copy this binary to ~/.hishtory/ and configure your shell to use it for recording your shell history",
|
Hidden: true,
|
||||||
|
Short: "Copy this binary to ~/.hishtory/ and configure your shell to use it for recording your shell history",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
lib.CheckFatalError(lib.Install())
|
lib.CheckFatalError(lib.Install())
|
||||||
if os.Getenv("HISHTORY_SKIP_INIT_IMPORT") == "" {
|
if os.Getenv("HISHTORY_SKIP_INIT_IMPORT") == "" {
|
||||||
|
@ -21,10 +21,13 @@ var EXAMPLE_QUERIES string = `Example queries:
|
|||||||
'hishtory SUBCOMMAND before:2022-02-01' # Find shell commands run before 2022-02-01
|
'hishtory SUBCOMMAND before:2022-02-01' # Find shell commands run before 2022-02-01
|
||||||
`
|
`
|
||||||
|
|
||||||
|
var GROUP_ID_QUERYING string = "group_id:querying"
|
||||||
|
|
||||||
var queryCmd = &cobra.Command{
|
var queryCmd = &cobra.Command{
|
||||||
Use: "query",
|
Use: "query",
|
||||||
Short: "Query your shell history",
|
Short: "Query your shell history and display the results in an ASCII art table",
|
||||||
Long: strings.ReplaceAll(EXAMPLE_QUERIES, "SUBCOMMAND", "query"),
|
GroupID: GROUP_ID_QUERYING,
|
||||||
|
Long: strings.ReplaceAll(EXAMPLE_QUERIES, "SUBCOMMAND", "query"),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
ctx := hctx.MakeContext()
|
ctx := hctx.MakeContext()
|
||||||
lib.CheckFatalError(lib.ProcessDeletionRequests(ctx))
|
lib.CheckFatalError(lib.ProcessDeletionRequests(ctx))
|
||||||
@ -33,9 +36,10 @@ var queryCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var tqueryCmd = &cobra.Command{
|
var tqueryCmd = &cobra.Command{
|
||||||
Use: "tquery",
|
Use: "tquery",
|
||||||
Short: "Interactively query your shell history",
|
Short: "Interactively query your shell history in a TUI interface",
|
||||||
Long: strings.ReplaceAll(EXAMPLE_QUERIES, "SUBCOMMAND", "tquery"),
|
GroupID: GROUP_ID_QUERYING,
|
||||||
|
Long: strings.ReplaceAll(EXAMPLE_QUERIES, "SUBCOMMAND", "tquery"),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
ctx := hctx.MakeContext()
|
ctx := hctx.MakeContext()
|
||||||
lib.CheckFatalError(lib.TuiQuery(ctx, strings.Join(args, " ")))
|
lib.CheckFatalError(lib.TuiQuery(ctx, strings.Join(args, " ")))
|
||||||
@ -43,9 +47,10 @@ var tqueryCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var exportCmd = &cobra.Command{
|
var exportCmd = &cobra.Command{
|
||||||
Use: "export",
|
Use: "export",
|
||||||
Short: "Export your shell history",
|
Short: "Export your shell history and display just the raw commands",
|
||||||
Long: strings.ReplaceAll(EXAMPLE_QUERIES, "SUBCOMMAND", "export"),
|
GroupID: GROUP_ID_QUERYING,
|
||||||
|
Long: strings.ReplaceAll(EXAMPLE_QUERIES, "SUBCOMMAND", "export"),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
ctx := hctx.MakeContext()
|
ctx := hctx.MakeContext()
|
||||||
lib.CheckFatalError(lib.ProcessDeletionRequests(ctx))
|
lib.CheckFatalError(lib.ProcessDeletionRequests(ctx))
|
||||||
|
@ -10,10 +10,14 @@ import (
|
|||||||
|
|
||||||
var force *bool
|
var force *bool
|
||||||
|
|
||||||
|
var GROUP_ID_MANAGEMENT string = "group_id_management"
|
||||||
|
|
||||||
var redactCmd = &cobra.Command{
|
var redactCmd = &cobra.Command{
|
||||||
Use: "redact",
|
Use: "redact",
|
||||||
Short: "Query for matching commands and remove them from your shell history",
|
Aliases: []string{"delete"},
|
||||||
Long: "This removes history entries on the current machine and on all remote machines. Supports the same query format as 'hishtory query'.",
|
Short: "Query for matching commands and remove them from your shell history",
|
||||||
|
Long: "This removes history entries on the current machine and on all remote machines. Supports the same query format as 'hishtory query'.",
|
||||||
|
GroupID: GROUP_ID_MANAGEMENT,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
ctx := hctx.MakeContext()
|
ctx := hctx.MakeContext()
|
||||||
lib.CheckFatalError(lib.RetrieveAdditionalEntriesFromRemote(ctx))
|
lib.CheckFatalError(lib.RetrieveAdditionalEntriesFromRemote(ctx))
|
||||||
|
@ -7,8 +7,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var reuploadCmd = &cobra.Command{
|
var reuploadCmd = &cobra.Command{
|
||||||
Use: "reupload",
|
Use: "reupload",
|
||||||
Short: "[Debug Only] Reupload your entire hiSHtory to all other devices",
|
Hidden: true,
|
||||||
|
Short: "[Debug Only] Reupload your entire hiSHtory to all other devices",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
lib.CheckFatalError(lib.Reupload(hctx.MakeContext()))
|
lib.CheckFatalError(lib.Reupload(hctx.MakeContext()))
|
||||||
},
|
},
|
||||||
|
@ -24,4 +24,8 @@ func Execute() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {}
|
func init() {
|
||||||
|
rootCmd.AddGroup(&cobra.Group{ID: GROUP_ID_QUERYING, Title: "History Searching"})
|
||||||
|
rootCmd.AddGroup(&cobra.Group{ID: GROUP_ID_MANAGEMENT, Title: "History Management"})
|
||||||
|
rootCmd.AddGroup(&cobra.Group{ID: GROUP_ID_CONFIG, Title: "Configuration"})
|
||||||
|
}
|
||||||
|
@ -15,8 +15,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var saveHistoryEntryCmd = &cobra.Command{
|
var saveHistoryEntryCmd = &cobra.Command{
|
||||||
Use: "saveHistoryEntry",
|
Use: "saveHistoryEntry",
|
||||||
// TODO: hide this from the help info?
|
Hidden: true,
|
||||||
|
Short: "[Internal-only] The command used to save history entries",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
ctx := hctx.MakeContext()
|
ctx := hctx.MakeContext()
|
||||||
lib.CheckFatalError(maybeUploadSkippedHistoryEntries(ctx))
|
lib.CheckFatalError(maybeUploadSkippedHistoryEntries(ctx))
|
||||||
|
@ -13,7 +13,7 @@ var verbose *bool
|
|||||||
|
|
||||||
var statusCmd = &cobra.Command{
|
var statusCmd = &cobra.Command{
|
||||||
Use: "status",
|
Use: "status",
|
||||||
Short: "View status info including the secret key which is needed to sync shell history from another machine",
|
Short: "View status info including the secret key which is needed to sync shell history from another machine",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
ctx := hctx.MakeContext()
|
ctx := hctx.MakeContext()
|
||||||
config := hctx.GetConf(ctx)
|
config := hctx.GetConf(ctx)
|
||||||
|
@ -15,4 +15,5 @@ Remaining things:
|
|||||||
* Support exclusions in searches
|
* Support exclusions in searches
|
||||||
* Figure out how to hide certain things from the help doc
|
* Figure out how to hide certain things from the help doc
|
||||||
* Figure out how to reorder the docs
|
* Figure out how to reorder the docs
|
||||||
|
* Acutally migrate saveHistoryEntry to cobra
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user