Use separate flag for skipping update config mods to enable future flexibility

This commit is contained in:
David Dworken
2024-10-20 09:20:43 -07:00
parent e8e167ed00
commit 8bb87f2d7a
2 changed files with 8 additions and 6 deletions

View File

@@ -26,10 +26,11 @@ import (
) )
var ( var (
offlineInit *bool offlineInit *bool
forceInit *bool forceInit *bool
offlineInstall *bool offlineInstall *bool
skipConfigModification *bool skipConfigModification *bool
skipUpdateConfigModification *bool
) )
var installCmd = &cobra.Command{ var installCmd = &cobra.Command{
@@ -45,7 +46,7 @@ var installCmd = &cobra.Command{
if strings.HasPrefix(secretKey, "-") { if strings.HasPrefix(secretKey, "-") {
lib.CheckFatalError(fmt.Errorf("secret key %#v looks like a CLI flag, please use a secret key that does not start with a -", secretKey)) lib.CheckFatalError(fmt.Errorf("secret key %#v looks like a CLI flag, please use a secret key that does not start with a -", secretKey))
} }
lib.CheckFatalError(install(secretKey, *offlineInstall, *skipConfigModification)) lib.CheckFatalError(install(secretKey, *offlineInstall, *skipConfigModification || *skipUpdateConfigModification))
if os.Getenv("HISHTORY_SKIP_INIT_IMPORT") == "" { if os.Getenv("HISHTORY_SKIP_INIT_IMPORT") == "" {
db, err := hctx.OpenLocalSqliteDb() db, err := hctx.OpenLocalSqliteDb()
lib.CheckFatalError(err) lib.CheckFatalError(err)
@@ -686,4 +687,5 @@ func init() {
forceInit = initCmd.Flags().Bool("force", false, "Force re-init without any prompts") forceInit = initCmd.Flags().Bool("force", false, "Force re-init without any prompts")
offlineInstall = installCmd.Flags().Bool("offline", false, "Install hiSHtory in offline mode with all syncing capabilities disabled") offlineInstall = installCmd.Flags().Bool("offline", false, "Install hiSHtory in offline mode with all syncing capabilities disabled")
skipConfigModification = installCmd.Flags().Bool("skip-config-modification", false, "Skip modifying shell configs and instead instruct the user on how to modify their configs") skipConfigModification = installCmd.Flags().Bool("skip-config-modification", false, "Skip modifying shell configs and instead instruct the user on how to modify their configs")
skipUpdateConfigModification = installCmd.Flags().Bool("skip-update-config-modification", false, "Skip modifying shell configs for updates")
} }

View File

@@ -112,7 +112,7 @@ func update(ctx context.Context) error {
if err != nil { if err != nil {
return fmt.Errorf("failed to chmod +x the update (stdout=%#v, stderr=%#v): %w", stdout.String(), stderr.String(), err) return fmt.Errorf("failed to chmod +x the update (stdout=%#v, stderr=%#v): %w", stdout.String(), stderr.String(), err)
} }
cmd = exec.Command(getTmpClientPath(), "install", "--skip-config-modification") cmd = exec.Command(getTmpClientPath(), "install", "--skip-update-config-modification")
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
stderr = bytes.Buffer{} stderr = bytes.Buffer{}
cmd.Stdin = os.Stdin cmd.Stdin = os.Stdin