mirror of
https://github.com/mas-cli/mas
synced 2024-11-24 20:43:10 +00:00
Use password prompt instead of passing directly, fixes #14
This commit is contained in:
parent
9020401e49
commit
f4bbe0e24e
2 changed files with 16 additions and 2 deletions
|
@ -56,6 +56,13 @@ To install all pending updates run `mas upgrade`.
|
|||
|
||||
To sign into the Mac App Store for the first time run `mas signin`.
|
||||
|
||||
$ mas signin mas@example.com
|
||||
==> Signing in to Apple ID: mas@example.com
|
||||
Password:
|
||||
|
||||
|
||||
You can also embed your password in the command.
|
||||
|
||||
$ mas signin mas@example.com "ZdkM4f$gzF;gX3ABXNLf8KcCt.x.np"
|
||||
==> Signing in to Apple ID: mas@example.com
|
||||
|
||||
|
|
|
@ -19,7 +19,14 @@ struct SignInCommand: CommandType {
|
|||
|
||||
do {
|
||||
print("==> Signing in to Apple ID: \(options.username)")
|
||||
try ISStoreAccount.signIn(username: options.username, password: options.password)
|
||||
|
||||
var password = options.password
|
||||
if password == ""
|
||||
{
|
||||
password = String.fromCString(getpass("Password: "))!
|
||||
}
|
||||
|
||||
try ISStoreAccount.signIn(username: options.username, password: password)
|
||||
} catch let error as NSError {
|
||||
return .Failure(MASError(code: .SignInError, sourceError: error))
|
||||
}
|
||||
|
@ -35,6 +42,6 @@ struct SignInOptions: OptionsType {
|
|||
static func evaluate(m: CommandMode) -> Result<SignInOptions, CommandantError<MASError>> {
|
||||
return curry(SignInOptions.init)
|
||||
<*> m <| Argument(usage: "Apple ID")
|
||||
<*> m <| Argument(usage: "Password")
|
||||
<*> m <| Argument(defaultValue: "", usage: "Password")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue