import { parseCmd } from './shell' ; export class AliasMap { aliases = new Map < string , string > ( ) ; replaceAll ( aliases ) { this . aliases = aliases ; } set ( alias , expansion ) { this . aliases . set ( alias , expansion ) ; } expand ( cmd ) { const first = cmd . split ( ' ' ) [ 0 ] ; let exp = this . aliases . get ( first ) ; if ( ! exp ) return cmd ; return exp + cmd . substring ( first . length ) ; } dump ( ) { return Array . from ( this . aliases . entries ( ) ) . map ( ( [ k , v ] ) => `alias ${ k }='${ v }'\n` ) . join ( '' ) ; } }