52 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
/*
 | 
						|
*               dotfiles - search.ts
 | 
						|
*
 | 
						|
*   Created by Janis Hutz 03/22/2025, Licensed under the GPL V3 License
 | 
						|
*           https://janishutz.com, development@janishutz.com
 | 
						|
*
 | 
						|
*
 | 
						|
*/
 | 
						|
 | 
						|
import subprocessRunner from "./subprocessRunner";
 | 
						|
import fzf from "./fzf";
 | 
						|
 | 
						|
const preprocess = ( input: string ) => {
 | 
						|
    // Find out what kind of instruction to process
 | 
						|
    if ( input.startsWith( ':' ) ) {
 | 
						|
        processCommand( input.substring( 1, input.indexOf( ' ' ) ), input.substring( input.indexOf( ' ' ) ).split( ' ' ) );
 | 
						|
    } else if ( input.startsWith( '!' ) ) {
 | 
						|
        processBang( input.substring( 1, input.indexOf( ' ' ) ), input.substring( input.indexOf( ' ' ) ) );
 | 
						|
    } else {
 | 
						|
        // Determine if entered string is calculation or not
 | 
						|
        // We can easily do that by asking qalc (qalculate cli) if this is fine
 | 
						|
        subprocessRunner.executeCommand( 'qalc "' + input + '"' ).then( out => {
 | 
						|
            // we get a calculation result here
 | 
						|
            print( out );
 | 
						|
            processCalculation( out );
 | 
						|
        } ).catch( err => {
 | 
						|
            processSearch( input );
 | 
						|
            print( err );
 | 
						|
        } );
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
const processSearch = ( input: string ) => {
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
const processCalculation = ( output: string ) => {
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
const processCommand = ( cmd: string, args: string[] ) => {
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
const processBang = ( bang: string, input: string ) => {
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
export default {
 | 
						|
    preprocess
 | 
						|
}
 |