-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* mercurywm: add alias command * mercurywm: add error messages to alias and env
- Loading branch information
1 parent
eda9909
commit b65d6e4
Showing
3 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* @flow strict */ | ||
|
||
import type { StoreState } from 'types'; | ||
|
||
/* This command has essentially the same logic as env.js */ | ||
export default function alias(state: StoreState, params: Array<string>) { | ||
if (!state.wsh.aliases) { | ||
state.wsh.aliases = {}; | ||
} | ||
if (params.length === 0) { | ||
Object.keys(state.wsh.aliases).forEach(e => { | ||
this.output(e + ': ' + state.wsh.aliases[e], false, false); | ||
}); | ||
} else if (params.length === 1) { | ||
if (!state.wsh.aliases[params[0]]) { | ||
this.output('\'' + params[0] + '\' is not aliased to anything!'); | ||
} else { | ||
this.output(params[0] + ': ' + state.wsh.aliases[params[0]], false, false); | ||
} | ||
} else if (params.length === 2) { | ||
// $FlowFixMe: command can mutate state | ||
if (!params[1]) { | ||
delete state.wsh.aliases[params[0]]; | ||
} else { | ||
state.wsh.aliases[params[0]] = params[1]; | ||
} | ||
} else { | ||
this.output('Invalid number of parameters'); | ||
} | ||
return state; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters