diff --git a/README.md b/README.md index 9a3d11d..87c0a46 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/mas-cli/Commands/SignIn.swift b/mas-cli/Commands/SignIn.swift index 519f1b3..d6626e1 100644 --- a/mas-cli/Commands/SignIn.swift +++ b/mas-cli/Commands/SignIn.swift @@ -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> { return curry(SignInOptions.init) <*> m <| Argument(usage: "Apple ID") - <*> m <| Argument(usage: "Password") + <*> m <| Argument(defaultValue: "", usage: "Password") } }