// import * as inquirer from "inquirer"; // import { inspect } from "../../lib/general"; // import { RemoteServer, StatusCodeError } from "../git"; // import { merge } from "lodash"; // import { Cli, Questions } from "../../app/cli"; // import * as Rx from "rx"; // import { config } from "../../app/config"; // // export var command: string = 'login [remote] [user] [password]'; // export var desc: string = 'Login to the remote and save credentials'; // export var builder = {} // // var cli: Cli = Cli.instance; // var data:any = { // remotes: ['server', 'github', 'bitbucket'], // remote: null, // // }; // // // export function handler( argv ) // { // let steps:any[] = [ // remote, // credentials, // login, // save // ]; // // async.waterfall(steps); // } // // function remote(done:any){ // Questions.askRemote().then(done); // } // // function credentials(done:any){ // done(); // } // // function save(done:any){} // // // // function handler2( argv, remote ) // { // // if ( !config.has(`git.login.${remote}.username`) ) { // enterCredentials(argv, remote).then(( data ) => // { // data.remote = remote; // login(data); // }) // } // else { // login(merge({ remote }, config(`git.login.${remote}`))); // } // } // function enterCredentials( argv, remote ) // { // // var prompts: {}[] = []; // // if ( !argv.user ) { // prompts.push({ name : 'username', type : 'input', message : 'Username' }); // } // if ( !argv.password ) { // prompts.push({ name : 'password', type : 'password', message : 'Enter your password' }); // } // // return ( inquirer.prompt(prompts)); // } // // function login( data ) // { // // if ( data.remote === 'server' ) { // let remote = new RemoteServer({ // host : 'git.radic.nl', // username : data.username, // password : data.password // }); // inspect(config(`git.login`)); // remote // .get('projects') // .then(( projects ) => // { // Cli.log(`{green}Success`); // config.set(`git.login.${data.remote}`, { username : data.username, password : data.password }); // console.log('success', projects) // }) // .catch(( err ) => // { // if ( err.name === 'StatusCodeError' ) { // const errors: any[] = JSON.parse(err.error).errors; // Cli.log(`{red}{_bold}Error while connecting to remote {/}{red}(${errors[0].exceptionName}){_bold}:`, errors[0].message) // // } // else { // console.log('error', err); // } // }); // // } // //login(data); // } // //