Use password prompt instead of passing directly, fixes #14

This commit is contained in:
Undo1 2016-06-08 14:23:55 -06:00
parent 9020401e49
commit f4bbe0e24e
2 changed files with 16 additions and 2 deletions

View file

@ -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

View file

@ -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")
} }
} }