Exemplo n.º 1
0
func runSetUser(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}
	if len(args) != 1 {
		stderr("set-user: incorrect number of arguments")
		return 1
	}

	lockfile, err := getLock()
	if err != nil {
		stderr("set-user: %v", err)
		return 1
	}
	defer func() {
		if err := releaseLock(lockfile); err != nil {
			stderr("set-user: %v", err)
			exit = 1
		}
	}()

	if debug {
		stderr("Setting user to %s", args[0])
	}

	err = lib.SetUser(tmpacipath(), args[0])

	if err != nil {
		stderr("set-user: %v", err)
		return 1
	}

	return 0
}
Exemplo n.º 2
0
func runSetUser(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}
	if len(args) != 1 {
		stderr("set-user: incorrect number of arguments")
		return 1
	}

	if debug {
		stderr("Setting user to %s", args[0])
	}

	err := lib.SetUser(tmpacipath(), args[0])

	if err != nil {
		stderr("set-user: %v", err)
		return 1
	}

	return 0
}