mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-25 06:22:24 +02:00
Organize command groupings in hishtory help + unhide the install command (#278)
This commit is contained in:
parent
2ff52a8d66
commit
95f3a26a7a
@ -15,8 +15,9 @@ import (
|
||||
)
|
||||
|
||||
var exportJsonCmd = &cobra.Command{
|
||||
Use: "export-json",
|
||||
Short: "Export history entries formatted in JSON lines format (as accepted by hishtory import-json, and easily parsable by other tools)",
|
||||
Use: "export-json",
|
||||
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) {
|
||||
ctx := hctx.MakeContext()
|
||||
err := exportToJson(ctx, os.Stdout)
|
||||
|
@ -17,10 +17,11 @@ import (
|
||||
)
|
||||
|
||||
var importCmd = &cobra.Command{
|
||||
Use: "import",
|
||||
Hidden: true,
|
||||
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`.",
|
||||
Use: "import",
|
||||
GroupID: GROUP_ID_MANAGEMENT,
|
||||
Hidden: true,
|
||||
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`.",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx := hctx.MakeContext()
|
||||
numImported, err := lib.ImportHistory(ctx, true, true)
|
||||
@ -32,8 +33,9 @@ var importCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
var importJsonCmd = &cobra.Command{
|
||||
Use: "import-json",
|
||||
Short: "Import history entries formatted in JSON lines format into hiSHtory",
|
||||
Use: "import-json",
|
||||
GroupID: GROUP_ID_MANAGEMENT,
|
||||
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" +
|
||||
"{\"command\":\"echo foo\"}\n" +
|
||||
"{\"command\":\"echo bar\", \"current_working_directory\": \"/tmp/\"}\n" +
|
||||
|
@ -36,11 +36,13 @@ var (
|
||||
currentlyInstalledVersion *string
|
||||
)
|
||||
|
||||
var GROUP_ID_INSTALL string = "group_id_install"
|
||||
|
||||
var installCmd = &cobra.Command{
|
||||
Use: "install",
|
||||
Hidden: true,
|
||||
Short: "Copy this binary to ~/.hishtory/ and configure your shell to use it for recording your shell history",
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
Use: "install",
|
||||
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),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
secretKey := ""
|
||||
if len(args) > 0 {
|
||||
@ -72,7 +74,7 @@ var installCmd = &cobra.Command{
|
||||
var initCmd = &cobra.Command{
|
||||
Use: "init",
|
||||
Short: "Re-initialize hiSHtory with a specified secret key",
|
||||
GroupID: GROUP_ID_CONFIG,
|
||||
GroupID: GROUP_ID_INSTALL,
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
db, err := hctx.OpenLocalSqliteDb()
|
||||
@ -107,8 +109,9 @@ var initCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
var uninstallCmd = &cobra.Command{
|
||||
Use: "uninstall",
|
||||
Short: "Completely uninstall hiSHtory and remove your shell history",
|
||||
Use: "uninstall",
|
||||
Short: "Completely uninstall hiSHtory and remove your shell history",
|
||||
GroupID: GROUP_ID_INSTALL,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx := hctx.MakeContext()
|
||||
fmt.Printf("Are you sure you want to uninstall hiSHtory and delete all locally saved history data [y/N]")
|
||||
|
@ -30,5 +30,6 @@ 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"})
|
||||
rootCmd.AddGroup(&cobra.Group{ID: GROUP_ID_INSTALL, Title: "Installation"})
|
||||
rootCmd.Version = "v0." + lib.Version
|
||||
}
|
||||
|
@ -22,8 +22,9 @@ import (
|
||||
)
|
||||
|
||||
var updateCmd = &cobra.Command{
|
||||
Use: "update",
|
||||
Short: "Securely update hishtory to the latest version",
|
||||
Use: "update",
|
||||
GroupID: GROUP_ID_INSTALL,
|
||||
Short: "Securely update hishtory to the latest version",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
lib.CheckFatalError(update(hctx.MakeContext()))
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user