mirror of
https://github.com/mas-cli/mas
synced 2024-11-22 03:23:08 +00:00
Merge pull request #30 from Undo1/master
Allow password prompt instead of command line argument
This commit is contained in:
commit
cf23a1bd01
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`.
|
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"
|
$ mas signin mas@example.com "ZdkM4f$gzF;gX3ABXNLf8KcCt.x.np"
|
||||||
==> Signing in to Apple ID: mas@example.com
|
==> Signing in to Apple ID: mas@example.com
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,14 @@ struct SignInCommand: CommandType {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
print("==> Signing in to Apple ID: \(options.username)")
|
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 {
|
} catch let error as NSError {
|
||||||
return .Failure(MASError(code: .SignInError, sourceError: error))
|
return .Failure(MASError(code: .SignInError, sourceError: error))
|
||||||
}
|
}
|
||||||
|
@ -35,6 +42,6 @@ struct SignInOptions: OptionsType {
|
||||||
static func evaluate(m: CommandMode) -> Result<SignInOptions, CommandantError<MASError>> {
|
static func evaluate(m: CommandMode) -> Result<SignInOptions, CommandantError<MASError>> {
|
||||||
return curry(SignInOptions.init)
|
return curry(SignInOptions.init)
|
||||||
<*> m <| Argument(usage: "Apple ID")
|
<*> m <| Argument(usage: "Apple ID")
|
||||||
<*> m <| Argument(usage: "Password")
|
<*> m <| Argument(defaultValue: "", usage: "Password")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue