@@ -5,6 +5,7 @@ import * as Result from '@web3-storage/w3up-client/result'
55import * as DidMailto from '@web3-storage/did-mailto'
66import { authorize } from '@web3-storage/capabilities/access'
77import { base64url } from 'multiformats/bases/base64'
8+ import { select } from '@inquirer/prompts'
89import { getClient } from './lib.js'
910import ora from 'ora'
1011
@@ -34,9 +35,24 @@ const getGithubOAuthClientID = serviceID => {
3435 * @param {boolean } [options.github]
3536 */
3637export const login = async ( email , options ) => {
38+ let method
3739 if ( email ) {
38- await loginWithClient ( email , await getClient ( ) )
40+ method = 'email'
3941 } else if ( options ?. github ) {
42+ method = 'github'
43+ } else {
44+ method = await select ( {
45+ message : 'How do you want to login?' ,
46+ choices : [
47+ { name : 'Via Email' , value : 'email' } ,
48+ { name : 'Via GitHub' , value : 'github' } ,
49+ ] ,
50+ } )
51+ }
52+
53+ if ( method === 'email' && email ) {
54+ await loginWithClient ( email , await getClient ( ) )
55+ } else if ( method === 'github' ) {
4056 await oauthLoginWithClient ( OAuthProviderGitHub , await getClient ( ) )
4157 } else {
4258 console . error ( 'Error: please provide email address or specify flag for alternate login method' )
0 commit comments