From 34918f3f8704e35ec7f9db532629f94abdfd39c4 Mon Sep 17 00:00:00 2001 From: Fernando Daciuk Date: Sun, 14 Jul 2024 22:38:10 -0300 Subject: [PATCH] feat: add option to override globals --- package.json | 3 ++- packages/cli/src/core/GlobalOptions.res | 2 +- packages/cli/src/core/Runner.res | 16 ++++++------- packages/cli/src/core/Tmux.res | 2 ++ pnpm-lock.yaml | 32 +++++++++++++++++-------- 5 files changed, 35 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 32cee2c..91679ee 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/packages/cli/src/core/GlobalOptions.res b/packages/cli/src/core/GlobalOptions.res index 0b4a033..6293f48 100644 --- a/packages/cli/src/core/GlobalOptions.res +++ b/packages/cli/src/core/GlobalOptions.res @@ -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)))) @@ -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)))) } diff --git a/packages/cli/src/core/Runner.res b/packages/cli/src/core/Runner.res index 1edf514..92bd9f0 100644 --- a/packages/cli/src/core/Runner.res +++ b/packages/cli/src/core/Runner.res @@ -3,7 +3,7 @@ type flags<'value> = {file: 'value, version: 'value} let run = async () => { let options: flags = { file: {type_: "string"}, - version: {type_: "boolean"} + version: {type_: "boolean"}, } let {values}: BunX.parseArgs>> = BunX.parseArgs({ @@ -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 🚀`) } } diff --git a/packages/cli/src/core/Tmux.res b/packages/cli/src/core/Tmux.res index 0b9b339..ffc0a13 100644 --- a/packages/cli/src/core/Tmux.res +++ b/packages/cli/src/core/Tmux.res @@ -23,6 +23,7 @@ type options = type command = | SetGlobal(options) + | SetOverrideGlobal(options) | Bind(string, string, array) let parseOptions = options => @@ -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(" ")}` } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c7785a9..2bbf2b5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,16 +11,19 @@ importers: '@changesets/cli': specifier: ^2.27.7 version: 2.27.7 + typescript: + specifier: ^5.5.3 + version: 5.5.3 devDependencies: '@release-it/bumper': specifier: ^6.0.1 - version: 6.0.1(release-it@17.5.0) + version: 6.0.1(release-it@17.5.0(typescript@5.5.3)) '@release-it/keep-a-changelog': specifier: ^5.0.0 - version: 5.0.0(release-it@17.5.0) + version: 5.0.0(release-it@17.5.0(typescript@5.5.3)) release-it: specifier: ^17.5.0 - version: 17.5.0 + version: 17.5.0(typescript@5.5.3) turbo: specifier: latest version: 2.0.4 @@ -1671,6 +1674,11 @@ packages: typedarray-to-buffer@3.1.5: resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==} + typescript@5.5.3: + resolution: {integrity: sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==} + engines: {node: '>=14.17'} + hasBin: true + undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} @@ -2079,7 +2087,7 @@ snapshots: '@pnpm/network.ca-file': 1.0.2 config-chain: 1.1.13 - '@release-it/bumper@6.0.1(release-it@17.5.0)': + '@release-it/bumper@6.0.1(release-it@17.5.0(typescript@5.5.3))': dependencies: '@iarna/toml': 2.2.5 detect-indent: 7.0.1 @@ -2087,13 +2095,13 @@ snapshots: ini: 4.1.3 js-yaml: 4.1.0 lodash-es: 4.17.21 - release-it: 17.5.0 + release-it: 17.5.0(typescript@5.5.3) semver: 7.6.2 - '@release-it/keep-a-changelog@5.0.0(release-it@17.5.0)': + '@release-it/keep-a-changelog@5.0.0(release-it@17.5.0(typescript@5.5.3))': dependencies: detect-newline: 4.0.1 - release-it: 17.5.0 + release-it: 17.5.0(typescript@5.5.3) string-template: 1.0.0 '@rescript/core@1.4.0(rescript@11.1.1)': @@ -2318,12 +2326,14 @@ snapshots: convert-to-spaces@2.0.1: {} - cosmiconfig@9.0.0: + cosmiconfig@9.0.0(typescript@5.5.3): dependencies: env-paths: 2.2.1 import-fresh: 3.3.0 js-yaml: 4.1.0 parse-json: 5.2.0 + optionalDependencies: + typescript: 5.5.3 cross-spawn@5.1.0: dependencies: @@ -3217,13 +3227,13 @@ snapshots: dependencies: rc: 1.2.8 - release-it@17.5.0: + release-it@17.5.0(typescript@5.5.3): dependencies: '@iarna/toml': 2.2.5 '@octokit/rest': 20.1.1 async-retry: 1.3.3 chalk: 5.3.0 - cosmiconfig: 9.0.0 + cosmiconfig: 9.0.0(typescript@5.5.3) execa: 8.0.1 git-url-parse: 14.0.0 globby: 14.0.2 @@ -3482,6 +3492,8 @@ snapshots: dependencies: is-typedarray: 1.0.0 + typescript@5.5.3: {} + undici-types@5.26.5: {} unicorn-magic@0.1.0: {}