mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-20 03:47:54 +02:00
Better organize the cobra generated help page
This commit is contained in:
parent
ecdd22dcdd
commit
27bbe97cb2
@ -9,6 +9,7 @@ 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()
|
||||||
},
|
},
|
||||||
|
@ -11,6 +11,7 @@ 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()
|
||||||
},
|
},
|
||||||
|
@ -11,6 +11,7 @@ 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()
|
||||||
},
|
},
|
||||||
|
@ -9,6 +9,7 @@ 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))
|
||||||
@ -18,6 +19,7 @@ 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))
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
var importCmd = &cobra.Command{
|
var importCmd = &cobra.Command{
|
||||||
Use: "import",
|
Use: "import",
|
||||||
|
Hidden: true,
|
||||||
Short: "Re-import history entries from your existing shell history",
|
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`.",
|
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) {
|
||||||
|
@ -16,6 +16,7 @@ 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",
|
||||||
|
GroupID: GROUP_ID_CONFIG,
|
||||||
Args: cobra.MaximumNArgs(1),
|
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()
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
var installCmd = &cobra.Command{
|
var installCmd = &cobra.Command{
|
||||||
Use: "install",
|
Use: "install",
|
||||||
|
Hidden: true,
|
||||||
Short: "Copy this binary to ~/.hishtory/ and configure your shell to use it for recording your shell history",
|
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())
|
||||||
|
@ -21,9 +21,12 @@ 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",
|
||||||
|
GroupID: GROUP_ID_QUERYING,
|
||||||
Long: strings.ReplaceAll(EXAMPLE_QUERIES, "SUBCOMMAND", "query"),
|
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()
|
||||||
@ -34,7 +37,8 @@ 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",
|
||||||
|
GroupID: GROUP_ID_QUERYING,
|
||||||
Long: strings.ReplaceAll(EXAMPLE_QUERIES, "SUBCOMMAND", "tquery"),
|
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()
|
||||||
@ -44,7 +48,8 @@ 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",
|
||||||
|
GroupID: GROUP_ID_QUERYING,
|
||||||
Long: strings.ReplaceAll(EXAMPLE_QUERIES, "SUBCOMMAND", "export"),
|
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()
|
||||||
|
@ -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",
|
||||||
|
Aliases: []string{"delete"},
|
||||||
Short: "Query for matching commands and remove them from your shell history",
|
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'.",
|
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))
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
var reuploadCmd = &cobra.Command{
|
var reuploadCmd = &cobra.Command{
|
||||||
Use: "reupload",
|
Use: "reupload",
|
||||||
|
Hidden: true,
|
||||||
Short: "[Debug Only] Reupload your entire hiSHtory to all other devices",
|
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"})
|
||||||
|
}
|
||||||
|
@ -16,7 +16,8 @@ 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))
|
||||||
|
@ -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