Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( GitVersion = "unknown" GitCommit = "unknown" BuildDate = "unknown" )
View Source
var ErrFileLocked = errors.New("file is locked")
View Source
var RootCmd = &cobra.Command{ Use: "pasuman", Short: "A command-line password manager", Version: "1.0.0", PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { cmd.SilenceUsage = true createDataFile := cmd == addCmd || cmd == masterPasswordCmd config.Init(rootCmdProfile, createDataFile) if cmd == removeLockCmd || cmd.Name() == cobra.ShellCompRequestCmd || cmd.Name() == cobra.ShellCompNoDescRequestCmd { return nil } lockFile := config.PasumanDataFile + ".lock" _, err := os.Stat(lockFile) if errors.Is(err, os.ErrNotExist) { if _, err := os.Create(lockFile); err != nil { return err } } else { return fmt.Errorf("%w: use `pasuman remove-lock` command to remove it "+ "(only if no other pasuman process is running!)", ErrFileLocked) } return nil }, PersistentPostRunE: func(cmd *cobra.Command, _ []string) error { if cmd.Name() == "__complete" { return nil } return RemoveLock() }, }
Functions ¶
func RemoveLock ¶
func RemoveLock() error
RemoveLock - removes the lock created by the `PersistentPreRunE` of the root command. We want to execute this even if the command fails (in the `RunE` part). If there is an error during RunE, PersistentPostRunE is not run. So as far as I know, we should also call `RemoveLock` manually in the `main.go`.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.