How to use the terminal-kit.autoComplete function in terminal-kit

To help you get started, we’ve selected a few terminal-kit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cronvel / http-requester / lib / HttpRequester.js View on Github external
}
	}

	//term.green( "\n'%s' '%s' '%s' '%s'\n" , typedImplicitFullPath , typedDir , typedFile , parentDirPath ) ;
	try {
		files = await fsKit.readdirAsync( parentDirPath , { slash: true , directories: true , files: ! onlyDir } ) ;
		if ( files.length ) { files.push( '../' ) ; }
	}
	catch ( error ) {
		return prefix + typedPath ;
	}

	//console.log( files ) ;
	if ( ! Array.isArray( files ) || ! files.length ) { return prefix + typedPath ; }

	completion = termkit.autoComplete( files , typedFile , true ) ;

	// force inputField() to prefix that *AFTER* singleLineMenu()
	if ( Array.isArray( completion ) ) { completion.prefix = prefix + typedDir ; }
	else { completion = prefix + typedDir + completion ; }

	return completion ;
} ;
github cronvel / http-requester / lib / shell.js View on Github external
}
	else if ( start.length >= 7 && start.slice( 0 , 7 ) === 'http://' ) {
		typedPath = start.slice( 7 ) ;
		return autoCompletePath( query , start , typedPath , 'http://' , false ) ;
	}
	else if ( start.length >= 8 && start.slice( 0 , 8 ) === 'https://' ) {
		typedPath = start.slice( 8 ) ;
		return autoCompletePath( query , start , typedPath , 'https://' , false ) ;
	}
	else if ( start.length >= 5 && start.slice( 0 , 5 ) === 'ws://' ) {
		typedPath = start.slice( 5 ) ;
		return autoCompletePath( query , start , typedPath , 'ws://' , false ) ;
	}

	// Use the default terminal-kit auto-completer with the client array of possibilities
	return termkit.autoComplete( this.clientAutoCompleteArray , start , true ) ;

} ;
github cronvel / http-requester / lib / HttpRequester.js View on Github external
}
	else if ( start.startsWith( 'http://' ) ) {
		typedPath = start.slice( 7 ) ;
		return this.autoCompletePath( start , typedPath , 'http://' , false ) ;
	}
	else if ( start.startsWith( 'https://' ) ) {
		typedPath = start.slice( 8 ) ;
		return this.autoCompletePath( start , typedPath , 'https://' , false ) ;
	}
	else if ( start.startsWith( 'ws://' ) ) {
		typedPath = start.slice( 5 ) ;
		return this.autoCompletePath( start , typedPath , 'ws://' , false ) ;
	}

	// Use the default terminal-kit auto-completer with the client array of possibilities
	return termkit.autoComplete( constants.clientAutoCompleteArray , start , true ) ;
} ;
github DefinitelyTyped / DefinitelyTyped / types / terminal-kit / terminal-kit-tests.ts View on Github external
fs.readdir(__dirname, (error, files) => {
    callback(undefined, ac(files, inputString, true));
  });
};
github cronvel / http-requester / lib / shell.js View on Github external
if ( typedPathArray[ typedPathArray.length - 1 ] === '' ) { typedPathArray.pop() ; }
	}

	prefix += typedDir ;
	node = pathArray.length ? tree.path.get( pathCompletion , pathArray ) : pathCompletion ;

	//console.log( '\n\nnode:' , node , pathArray ) ;

	if ( ! node || typeof node !== 'object' ) { return start ; }

	for ( key in node ) {
		if ( node[ key ] && typeof node[ key ] === 'object' ) { completion.push( key + '/' ) ; }
		else { completion.push( key ) ; }
	}

	completion = termkit.autoComplete( completion , lastTypedPart , true ) ;
	if ( ! Array.isArray( completion ) ) { return prefix + completion ; }

	completion.sort( naturalSort ) ;
	completion.prefix = prefix ;

	return completion ;
}
github cronvel / http-requester / lib / HttpRequester.js View on Github external
if ( typedPathArray[ typedPathArray.length - 1 ] === '' ) { typedPathArray.pop() ; }
	}

	prefix += typedDir ;
	node = pathArray.length ? tree.path.get( this.pathCompletion , pathArray ) : this.pathCompletion ;

	//console.log( '\n\nnode:' , node , pathArray ) ;

	if ( ! node || typeof node !== 'object' ) { return start ; }

	for ( key in node ) {
		if ( node[ key ] && typeof node[ key ] === 'object' ) { completion.push( key + '/' ) ; }
		else { completion.push( key ) ; }
	}

	completion = termkit.autoComplete( completion , lastTypedPart , true ) ;
	if ( ! Array.isArray( completion ) ) { return prefix + completion ; }

	completion.sort( naturalSort ) ;
	completion.prefix = prefix ;

	return completion ;
} ;
github cronvel / terminal-kit / sample / input-field-doc3.js View on Github external
fs.readdir( __dirname , function( error , files ) {
        callback( undefined , termkit.autoComplete( files , inputString , true , prefix ) ) ;
    } ) ;
} ;
github cronvel / terminal-kit / sample / input-field-doc2.js View on Github external
fs.readdir( __dirname , function( error , files ) {
        callback( undefined , termkit.autoComplete( files , inputString , true ) ) ;
    } ) ;
} ;