Skip to content

Commit

Permalink
feat: add option to override globals
Browse files Browse the repository at this point in the history
  • Loading branch information
fdaciuk authored and vmarcosp committed Jul 15, 2024
1 parent 20a03c7 commit 34918f3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 20 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"packageManager": "pnpm@9.0.0",
"version": "0.0.12",
"dependencies": {
"@changesets/cli": "^2.27.7"
"@changesets/cli": "^2.27.7",
"typescript": "^5.5.3"
}
}
2 changes: 1 addition & 1 deletion packages/cli/src/core/GlobalOptions.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ let tap = (opt, fn) => opt->Option.map(value => fn(value))->ignore

let execute = (options: Config.options) => {
options.mouse->tap(v => Tmux.exec(SetGlobal(Mouse(v))))
options.terminalOverrides->tap(v => Tmux.exec(SetGlobal(TerminalOverrides(v))))
options.escapeTime->tap(v => Tmux.exec(SetGlobal(EscapeTime(v))))
options.paneBaseIndex->tap(v => Tmux.exec(SetGlobal(PaneBaseIndex(v))))
options.statusKeys->tap(v => Tmux.exec(SetGlobal(StatusKeys(v))))
Expand All @@ -13,6 +12,7 @@ let execute = (options: Config.options) => {
options.baseIndex->tap(v => Tmux.exec(SetGlobal(BaseIndex(v))))
options.historyLimit->tap(v => Tmux.exec(SetGlobal(HistoryLimit(v))))
options.defaultTerminal->tap(v => Tmux.exec(SetGlobal(DefaultTerminal(v))))
options.terminalOverrides->tap(v => Tmux.exec(SetOverrideGlobal(TerminalOverrides(v))))
options.renumberWindows->tap(v => Tmux.exec(SetGlobal(RenumberWindows(v))))
options.aggressiveResize->tap(v => Tmux.exec(SetGlobal(AggressiveResize(v))))
}
Expand Down
16 changes: 8 additions & 8 deletions packages/cli/src/core/Runner.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type flags<'value> = {file: 'value, version: 'value}
let run = async () => {
let options: flags<BunX.flag> = {
file: {type_: "string"},
version: {type_: "boolean"}
version: {type_: "boolean"},
}

let {values}: BunX.parseArgs<flags<option<string>>> = BunX.parseArgs({
Expand All @@ -18,23 +18,23 @@ let run = async () => {
| Some(file) => {
let path = Path.resolve([file])
let {default: config} = await Config.import_(path)

Renderer.render(config)

switch config.options {
| None => ()
| Some(options) => GlobalOptions.execute(options)
| None => ()
| Some(options) => GlobalOptions.execute(options)
}

switch config.bindings {
| None => ()
| Some(bindings) => Bindings.execute(bindings)
| None => ()
| Some(bindings) => Bindings.execute(bindings)
}
}
}

switch values.version {
| None => ()
| Some(_) => Console.log(`better-tmux 🚀`)
| None => ()
| Some(_) => Console.log(`better-tmux 🚀`)
}
}
2 changes: 2 additions & 0 deletions packages/cli/src/core/Tmux.res
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type options =

type command =
| SetGlobal(options)
| SetOverrideGlobal(options)
| Bind(string, string, array<string>)

let parseOptions = options =>
Expand Down Expand Up @@ -53,6 +54,7 @@ let parseOptions = options =>
let parse = command =>
switch command {
| SetGlobal(options) => `tmux set -g ${options->parseOptions}`
| SetOverrideGlobal(options) => `tmux set -ga ${options->parseOptions}`
| Bind(key, command, options) => `tmux bind ${key} ${command} ${options->Array.join(" ")}`
}

Expand Down
32 changes: 22 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 34918f3

Please sign in to comment.