2022-03-12 22:43:32 -08:00
|
|
|
package cli
|
2022-03-12 13:04:08 -08:00
|
|
|
|
|
|
|
import (
|
2022-03-19 11:48:37 -07:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"time"
|
|
|
|
|
2022-03-12 13:04:08 -08:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
// configCmd represents the config command
|
|
|
|
var configCmd = &cobra.Command{
|
2022-03-19 11:48:37 -07:00
|
|
|
Use: "config [export|migrate|edit]",
|
2022-05-05 02:26:20 -07:00
|
|
|
Short: "Interact with the config",
|
|
|
|
Long: `Interact with the config.
|
|
|
|
|
|
|
|
You can export, migrate or edit the config.`,
|
|
|
|
ValidArgs: []string{
|
|
|
|
"export",
|
|
|
|
"migrate",
|
|
|
|
"edit",
|
|
|
|
"get",
|
|
|
|
},
|
|
|
|
Args: NoArgsOrOneValidArg,
|
2022-03-19 11:48:37 -07:00
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
if len(args) == 0 {
|
|
|
|
_ = cmd.Help()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
switch args[0] {
|
|
|
|
case "edit":
|
|
|
|
editFileWithEditor(os.Getenv("POSH_THEME"))
|
|
|
|
case "get":
|
|
|
|
// only here for backwards compatibility
|
|
|
|
fmt.Print(time.Now().UnixNano() / 1000000)
|
|
|
|
default:
|
|
|
|
_ = cmd.Help()
|
|
|
|
}
|
|
|
|
},
|
2022-03-12 13:04:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() { // nolint:gochecknoinits
|
|
|
|
rootCmd.AddCommand(configCmd)
|
|
|
|
}
|