Ask for git remote in local store setup
Fixes
@@ -215,10 +215,29 @@ func (s *Action) initLocal(ctx context.Context, c *cli.Context) error {
out.Green(ctx, " -> OK")
out.Print(ctx, "Configuring your local store ...")
+
+ if want, err := s.askForBool(ctx, "Do you want to add a git remote?", false); err == nil && want {
+ out.Print(ctx, "Configuring the git remote ...")
+ remote, err := s.askForString(ctx, "Please enter the git remote for your store", "")
+ if err != nil {
+ return errors.Wrapf(err, "failed to read user input")
+ }
+ {
+ ctx := out.WithHidden(ctx, true)
+ if err := s.Store.Git(ctx, "", false, false, "remote", "add", "origin", remote); err != nil {
+ return errors.Wrapf(err, "failed to add git remote")
+ }
+ if err := s.Store.Git(ctx, "", false, false, "push", "origin", "master"); err != nil {
+ return errors.Wrapf(err, "failed to push to git remote")
+ }
+ }
// autosync
if want, err := s.askForBool(ctx, "Do you want to automatically push any changes to the git remote (if any)?", true); err == nil {
s.cfg.Root.AutoSync = want
}
+ } else {
+ s.cfg.Root.AutoSync = false
+ }
// noconfirm
if want, err := s.askForBool(ctx, "Do you want to always confirm recipients when encrypting?", false); err == nil {
