Beispiel #1
0
const render = () => {
	term.fullscreen();
	term.inverse( padLine( 'Use the arrow keys and BACKSPACE to navigate, ENTER to select, and ESC to quit' ) );
	term( '\n' );
	term.bold( padLine( `--- ${ current.path } `, '-' ) );

	if ( menu ) {
		menu.abort();
	}

	menu = term.singleColumnMenu(
		getMenu( current, term.height - 4 ),
		{ selectedIndex: current.index },
		( error, { selectedIndex } ) => {
			const selectedDirectory = current.items[ selectedIndex ].name;
			const selectedPath = path.resolve( current.path, selectedDirectory );
			const stats = fs.statSync( selectedPath );

			if ( stats.isDirectory() ) {
				current = Folder( selectedPath );
			} else {
				current.index = selectedIndex;

				term.bell();
			}

			render();
		} );
};
term.singleLineMenu( items , options , function( error , response ) {
	term( '\n' ).eraseLineAfter.green(
		"#%s selected: %s (%s,%s)\n" ,
		response.selectedIndex ,
		response.selectedText ,
		response.x ,
		response.y
	) ;
	process.exit() ;
} ) ;
Beispiel #3
0
var printTweets = function(){
	term.slowTyping(
	  	term(latestTweets) ,
	  	{ 
	  		flashStyle: term.yellow,
			delay: 10, 
	  	},
	 	function(){ process.exit(); }
	 ); 

}
Beispiel #4
0
 this._textInput = term.inputField( (error, input) => {
   term('\n')
   if (error) {
     log.error(error)
     reject(error)
   }
   else {
     resolve(input)
   }
   this.exitTextEntry()
 })
Beispiel #5
0
	tweetClient.get('statuses/user_timeline', params, function(error, tweets, response){
		if (!error){
			for (var i = 0; i < 10; i++){
				 lastestTweets.push(tweets[i].text);
				 console.log(tweets[i].text)
			}
			
		}else{
			term(error)
		}
		
	});	// process.exit();
Beispiel #6
0
module.exports = function(args = {}) {
  try {
    pkg    = req('package.json');
  } catch(e) {
    term.red.error("There is no initialized project in this directory!\n");
    process.exit(e.code);
  }

  term.cyan("^_Project directory:\n");
  term(path.join(path.basename(cwd),"/") + "\n");
  // project name and version
  if (/^(version|name)$/.test(args[0]) || args[0] === undefined) {
    term.cyan("^_Project name:\n");
    term(pkg.name + " v" + pkg.version + "\n");
    if (args[0] !== undefined) process.exit(0);
  }
  // template version
  if (pkg.description && args[0] === "description" || args[0] === undefined) {
    term.cyan("^_Project description:\n");
    term(pkg.description + "\n");
  }

}
Beispiel #7
0
cli.request = async function( query ) {
	const HttpRequester = require( './HttpRequester.js' ) ;
	var streams = {} , incomingMessage , body ,
		httpRequester = new HttpRequester( query ) ;

	try {
		if ( query.output ) {
			streams.output = fs.createWriteStream( query.output ) ;
			await Promise.onceEventOrError( streams.output , 'open' ) ;
		}

		body = await httpRequester.performRequest( query , {
			output: streams.output ,
			headerCallback: incomingMessage_ => {
				incomingMessage = incomingMessage_ ;
				httpRequester.displayHeader( incomingMessage ) ;
			} ,
			progressCallback: httpRequester.displayProgressBar.bind( httpRequester , {} )
		} ) ;
	}
	catch( error ) {
		term.red( error.toString() + '\n' ) ;
		process.exit( 1 ) ;
	}

	term( '\n' ) ;

	if ( ! streams.output ) {
		httpRequester.displayBody( body , incomingMessage ) ;
		httpRequester.displayTrailer( incomingMessage ) ;
	}

	term.dim.magenta( '[Received ' +
	( body ? utils.byteString( body.length ) + ' ' : '' ) +
	'in ' + httpRequester.lastResponse.time + 'ms]\n' ) ;

	term.processExit( 0 ) ;
} ;
		setTimeout( function() { term( '\n' ) ; process.exit() ; } , 200 ) ;
	The above copyright notice and this permission notice shall be included in all
	copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
	SOFTWARE.
*/
"use strict" ;

var term = require( 'terminal-kit' ).terminal ;

term( '> ' ) ;

var autoComplete = [
	'dnf install' ,
	'dnf install nodejs' ,
	'dnf search' ,
	'sudo' ,
	'sudo dnf install' ,
	'sudo dnf install nodejs' ,
	'sudo dnf search' ,
] ;

term.inputField(
	{
		autoComplete: autoComplete ,
		autoCompleteHint: true ,
Beispiel #10
0
 proxy.server.termEvents.on('log', txt => term(txt))
Beispiel #11
0
var promptCustomer = function(res) {
        //PROMPTS USER FOR WHAT THEY WOULD LIKE TO PURCHASE//
        term('\nHit tab to autocomplete\n')
        term('What would you like to purchase?: ');
        term.inputField({
            history: history,
            autoComplete: autoComplete,
            autoCompleteMenu: true
        }, function(error, input){
            term.green('\nYou selected: '+ input + '\n')
            term.yellow('Do you want to purchase this item? [Y/N]\n');
            term.yesOrNo({
                yes: ['Y', 'ENTER', 'y'],
                no: ['N', 'n']
            }, function(error, result){
                if(result){
                    var prod = checkInStock(input, inventory, function(prod){
                        if(prod[0] != null){

                            term.blue('There are ' + prod[0].StockQuantity + ' left in stock ')
                            term.blue('You have chosen to purchase ' + prod[0].ProductName + '\n');
                            var id = prod[0].ItemID;
                            var quantity = prod[0].StockQuantity - 1;
                            connection.query('UPDATE products SET StockQuantity= ' + quantity + ' WHERE ItemID='+ id +';', function(err, res){
                                if(err){
                                    console.error('error connectiong: ' + err.stack)
                                } else {
                                    term.green('You have successfully purchased a ' + prod[0].ProductName);
                                    process.exit();
                                }
                            })

                        } else {
                            term.blue('Sorry it looks like '+ input +' is out of stock. \n');
                            term.blue('We have ordered more of this item, check back soon');
                            promptCustomer(res);
                        }
                    });

                } else {
                    term.blue(input);
                    term.red('You do not want to purchase this item.')
                    process.exit()
                    promptCustomer(res)
                }
            })
            // process.exit()
        })
        // inquirer.prompt([{
        //     type: 'input',
        //     name: 'choice',
        //     message: 'What would you like to purchase?'
        // }]).then(function(val){
        //     console.log('some value')
        // }).then(function(val){
        //     var correct = false;
        //     console.log(val)
        //     for (var i=0; i<res.length; i++){
        //     }
        // })
        // .then(function(val) {​
        //         //SET THE VAR correct TO FALSE SO AS TO MAKE SURE THE USER INPUTS A VALID PRODUCT NAME//
        //         var correct = false;
        //         //LOOPS THROUGH THE MYSQL TABLE TO CHECK THAT THE PRODUCT THEY WANTED EXISTS//
        //         for (var i = 0; i < res.length; i++) {
	    //             //1. todo: IF THE PRODUCT EXISTS, SET correct = true and ASK THE USER TO SEE HOW MANY OF THE PRODUCT THEY WOULD LIKE TO BUY//
	    //            	//2. todo: CHECK TO SEE IF THE AMOUNT REQUESTED IS LESS THAN THE AMOUNT THAT IS AVAILABLE//
	    //             //3. todo: UPDATE THE MYSQL TO REDUCE THE StockQuanaity by the THE AMOUNT REQUESTED  - UPDATE COMMAND!
	    //             //4. todo: SHOW THE TABLE again by calling the function that makes the table
        //         }
        //
        //         //IF THE PRODUCT REQUESTED DOES NOT EXIST, RESTARTS PROMPT//
        //         if (i == res.length && correct == false) {
        //             promptCustomer(res);
        //         }
        //     });
}
#!/usr/bin/env node

"use strict" ;

var term = require( 'terminal-kit' ).terminal ;

var history = [ 'John' , 'Jack' , 'Joey' , 'Billy' , 'Bob' ] ;

var autoComplete = [
	'Barack Obama' , 'George W. Bush' , 'Bill Clinton' , 'George Bush' ,
	'Ronald W. Reagan' , 'Jimmy Carter' , 'Gerald Ford' , 'Richard Nixon' ,
	'Lyndon Johnson' , 'John F. Kennedy' , 'Dwight Eisenhower' ,
	'Harry Truman' , 'Franklin Roosevelt'
] ;

term( 'Please enter your name: ' ) ;

term.inputField(
	{ history: history , autoComplete: autoComplete , autoCompleteMenu: true } ,
	function( error , input ) {

		term.green( "\nYour name is '%s'\n" , input ) ;
		process.exit() ;
	}
) ;