-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
whoami command #10
Comments
May I implement this one ? |
Of course. It is on you @betelgeuse-7 |
Thanks! |
Is it okay if I don't use |
I am planning to implement other commands, and I don't like to use an abstraction for such small applications. |
I had implemented it like this: const (
_HELP = `Usage: whoami [OPTION]
Print the user name associated with the current effective user ID.
Same as id -un.
--help, -h display this help and exit
--version, -v output version information and exit
`
_VERSION = "0.0.1"
_CMDNAME = "whoami"
)
func whoami(args []string) error {
argsLen := len(args)
switch argsLen {
case 1:
// only program name
u, err := user.Current()
if err != nil {
return err
}
fmt.Println(u.Username)
case 2:
arg := args[1]
switch arg {
case "--help", "-h":
fmt.Print(_HELP)
case "--version", "-v":
fmt.Printf("whoami - version %s\n", _VERSION)
default:
return fmt.Errorf("unknown command '%s'; pass '--help', or '-h' for help information", arg)
}
default:
return fmt.Errorf("excessive number of arguments (%d)", argsLen)
}
return nil
}
func Run(args []string) error {
return whoami(args)
}
/// TESTS OK then... Good luck |
You can deassign me |
@betelgeuse-7 I would like you to complete the PR if it is OK with you. You could have just used the lines you wrote with a command template like echo here
|
Alright, I deassigned you. |
Closed by #18 |
Sorry for wasting your time. I hopped into this without actually reading the code-base. |
Get the active username command.
The text was updated successfully, but these errors were encountered: