Skip to content

Commit 6b03c3a

Browse files
authored
Simplify socket wrapper with on/off args (#631)
* Simplify socket wrapper with on/off args * snapshot
1 parent a376467 commit 6b03c3a

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/commands/wrapper/cmd-wrapper.mts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { removeSocketWrapper } from './remove-socket-wrapper.mts'
99
import constants from '../../constants.mts'
1010
import { commonFlags } from '../../flags.mts'
1111
import { checkCommandInput } from '../../utils/check-input.mts'
12+
import { isTestingV1 } from '../../utils/config.mts'
1213
import { getOutputKind } from '../../utils/get-output-kind.mts'
1314
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
1415
import { getFlagListOutput } from '../../utils/output-formatting.mts'
@@ -71,21 +72,37 @@ async function run(
7172
parentName,
7273
})
7374

74-
const { disable, enable, json, markdown } = cli.flags
75+
const { json, markdown } = cli.flags
76+
let { disable, enable } = cli.flags
7577
const outputKind = getOutputKind(json, markdown) // TODO: impl json/md further
7678

79+
if (isTestingV1()) {
80+
const [arg] = cli.input
81+
if (arg === 'on' || arg === 'enable' || arg === 'enabled') {
82+
enable = true
83+
disable = false
84+
} else if (arg === 'off' || arg === 'disable' || arg === 'disabled') {
85+
enable = false
86+
disable = true
87+
}
88+
}
89+
7790
const wasValidInput = checkCommandInput(
7891
outputKind,
7992
{
8093
test: !!(enable || disable),
81-
message: 'Must use --enabled or --disable',
94+
message: isTestingV1()
95+
? 'Must use on or off argument'
96+
: 'Must use --enable or --disable',
8297
pass: 'ok',
8398
fail: 'missing',
8499
},
85100
{
86101
nook: true,
87102
test: !enable || !disable,
88-
message: 'Do not use both --enable and --disable',
103+
message: isTestingV1()
104+
? 'Do not use both on and off'
105+
: 'Do not use both --enable and --disable',
89106
pass: 'ok',
90107
fail: 'missing',
91108
},

src/commands/wrapper/cmd-wrapper.test.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('socket wrapper', async () => {
6161
6262
\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[1m\\x1b[37m Input error: \\x1b[39m\\x1b[22m\\x1b[49m \\x1b[1mPlease review the input requirements and try again
6363
64-
- Must use --enabled or --disable (\\x1b[31mmissing\\x1b[39m)
64+
- Must use --enable or --disable (\\x1b[31mmissing\\x1b[39m)
6565
\\x1b[22m"
6666
`)
6767

0 commit comments

Comments
 (0)