Organize command groupings in hishtory help + unhide the install command (#278)

This commit is contained in:
David Dworken 2025-01-05 18:18:07 -05:00 committed by GitHub
parent 2ff52a8d66
commit 95f3a26a7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 25 additions and 17 deletions

View File

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

View File

@ -18,6 +18,7 @@ import (
var importCmd = &cobra.Command{ var importCmd = &cobra.Command{
Use: "import", Use: "import",
GroupID: GROUP_ID_MANAGEMENT,
Hidden: true, 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 may also pipe commands to be imported in via stdin. For example `history | hishtory import`.", Long: "Note that you may also pipe commands to be imported in via stdin. For example `history | hishtory import`.",
@ -33,6 +34,7 @@ var importCmd = &cobra.Command{
var importJsonCmd = &cobra.Command{ var importJsonCmd = &cobra.Command{
Use: "import-json", Use: "import-json",
GroupID: GROUP_ID_MANAGEMENT,
Short: "Import history entries formatted in JSON lines format into hiSHtory", Short: "Import history entries formatted in JSON lines format into hiSHtory",
Long: "Data is read from stdin. For example: `cat data.txt | hishtory import-json`.\n\nExample JSON format:\n\n```\n" + Long: "Data is read from stdin. For example: `cat data.txt | hishtory import-json`.\n\nExample JSON format:\n\n```\n" +
"{\"command\":\"echo foo\"}\n" + "{\"command\":\"echo foo\"}\n" +

View File

@ -36,10 +36,12 @@ var (
currentlyInstalledVersion *string currentlyInstalledVersion *string
) )
var GROUP_ID_INSTALL string = "group_id_install"
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",
GroupID: GROUP_ID_INSTALL,
Args: cobra.MaximumNArgs(1), Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
secretKey := "" secretKey := ""
@ -72,7 +74,7 @@ var installCmd = &cobra.Command{
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, GroupID: GROUP_ID_INSTALL,
Args: cobra.MaximumNArgs(1), Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
db, err := hctx.OpenLocalSqliteDb() db, err := hctx.OpenLocalSqliteDb()
@ -109,6 +111,7 @@ var initCmd = &cobra.Command{
var uninstallCmd = &cobra.Command{ var uninstallCmd = &cobra.Command{
Use: "uninstall", Use: "uninstall",
Short: "Completely uninstall hiSHtory and remove your shell history", Short: "Completely uninstall hiSHtory and remove your shell history",
GroupID: GROUP_ID_INSTALL,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
ctx := hctx.MakeContext() ctx := hctx.MakeContext()
fmt.Printf("Are you sure you want to uninstall hiSHtory and delete all locally saved history data [y/N]") fmt.Printf("Are you sure you want to uninstall hiSHtory and delete all locally saved history data [y/N]")

View File

@ -30,5 +30,6 @@ func init() {
rootCmd.AddGroup(&cobra.Group{ID: GROUP_ID_QUERYING, Title: "History Searching"}) 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_MANAGEMENT, Title: "History Management"})
rootCmd.AddGroup(&cobra.Group{ID: GROUP_ID_CONFIG, Title: "Configuration"}) rootCmd.AddGroup(&cobra.Group{ID: GROUP_ID_CONFIG, Title: "Configuration"})
rootCmd.AddGroup(&cobra.Group{ID: GROUP_ID_INSTALL, Title: "Installation"})
rootCmd.Version = "v0." + lib.Version rootCmd.Version = "v0." + lib.Version
} }

View File

@ -23,6 +23,7 @@ import (
var updateCmd = &cobra.Command{ var updateCmd = &cobra.Command{
Use: "update", Use: "update",
GroupID: GROUP_ID_INSTALL,
Short: "Securely update hishtory to the latest version", Short: "Securely update hishtory to the latest version",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
lib.CheckFatalError(update(hctx.MakeContext())) lib.CheckFatalError(update(hctx.MakeContext()))