Open Rishi-0007 opened 1 week ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
robo | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 28, 2024 8:37pm |
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅
I have read the CLA Document and I hereby sign the CLA
Thank you for this! Can you please verify that multi-arg options are still possible? If so, how does the API distinguish between them?
For example, a --plugins
option should still be able to accept multiple values. (e.g. "--plugins @robojs/ai @robojs/sync")
Thank you for this! Can you please verify that multi-arg options are still possible? If so, how does the API distinguish between them?
For example, a
--plugins
option should still be able to accept multiple values. (e.g. "--plugins @robojs/ai @robojs/sync")
Hey @Pkmmte , I've made the changes based on your feedback. Please check it and let me know if this approach is good or any further changes are required.
Hi @Pkmmte,
Thank you for your feedback and for accepting the PR for Hacktoberfest. I’ve been working on addressing the issues mentioned, specifically ensuring options like -v
after positional arguments are correctly parsed and not treated as file paths.
Here’s what I’ve tried so far:
parseOptions
in cli-handler.ts
: Refined the parsing logic to separate options from positional arguments and ensure options with spaces return single strings by default.Encountering Persistent ENOENT
Error: When running the command:
npx robo build src/cli/commands/add.ts -v
the -v
flag continues to be interpreted as a positional argument, causing an attempt to locate a file at -v
, and resulting in the ENOENT
error. This behavior appears on both the main branch and my modified branch, suggesting it may be due to the overall handling of positional arguments in the build
command.
Would you be able to provide additional guidance on addressing this issue? Specifically, are there any expected parsing behaviors or modifications within cli-handler.ts
that would prevent options like -v
from being treated as positional arguments in the context of the build
command?
Thank you for your time and assistance.
Hello ! thanks for your contribution, I have just tested it out, and it seems to be working just fine for me, are you sure to be testing out the right branch ?
Hello ! thanks for your contribution, I have just tested it out, and it seems to be working just fine for me, are you sure to be testing out the right branch ?
Hi @Nazeofel, Thanks for testing it out. Is this the expected output or am I doing something wrong?
npx robo build src/cli/commands/add.ts -v
info - Building Robo...
node:internal/fs/promises:1032
const result = await PromisePrototypeThen(
^
Error: ENOENT: no such file or directory, stat '/home/rishi/code/robo.js/packages/robo/-v'
at async Object.stat (node:internal/fs/promises:1032:18)
at async traverse (file:///home/rishi/code/robo.js/packages/robo/dist/cli/utils/compiler.js:59:1
8) at async Object.buildCode (file:///home/rishi/code/robo.js/packages/robo/dist/cli/utils/compiler
.js:133:3) at async Command.buildAction [as _handler] (file:///home/rishi/code/robo.js/packages/robo/dist/c
li/commands/build/index.js:63:23) at async Command.processSubCommand (file:///home/rishi/code/robo.js/packages/robo/dist/cli/utils
/cli-handler.js:255:5) at async Command.processSubCommand (file:///home/rishi/code/robo.js/packages/robo/dist/cli/utils
/cli-handler.js:245:9) { errno: -2,
code: 'ENOENT',
syscall: 'stat',
path: '/home/rishi/code/robo.js/packages/robo/-v'
}
Node.js v22.9.0
But when I removed -v
, I got this output(which is not an error I guess):
npx robo build src/cli/commands/add.ts
info - Building Robo...
Type Name Description
───────────────────────────────────────────────
Command Δ /help Displays a list of commands.
Event Δ interactionCreate
Event Δ ready
Δ = Automatically generated
Robo size: 836.92 kB
Built in 113ms
discord:error - DISCORD_TOKEN or DISCORD_CLIENT_ID not found in environment variables
Is this what you are talking about in the previous comment @Pkmmte?
Hey @Pkmmte,
I’ve tested the issue on the main branch as well and observed the following outputs in two cases:
Without -v
:
npx robo build src/cli/commands/add.ts
info - Building Robo...
Type Name Description
───────────────────────────────────────────────
Command Δ /help Displays a list of commands.
Event Δ interactionCreate
Event Δ ready
Δ = Automatically generated
Robo size: 836.59 kB
Built in 109ms
discord:error - DISCORD_TOKEN or DISCORD_CLIENT_ID not found in environment variables
With -v
:
npx robo build src/cli/commands/add.ts -v
info - Building Robo...
node:internal/fs/promises:1032
const result = await PromisePrototypeThen(
^
Error: ENOENT: no such file or directory, stat '/home/rishi/code/robo.js/packages/robo/-v'
at async Object.stat (node:internal/fs/promises:1032:18)
at async traverse (file:///home/rishi/code/robo.js/packages/robo/dist/cli/utils/compiler.js:59:1
8) at async Object.buildCode (file:///home/rishi/code/robo.js/packages/robo/dist/cli/utils/compiler
.js:133:3) at async Command.buildAction [as _handler] (file:///home/rishi/code/robo.js/packages/robo/dist/c
li/commands/build/index.js:63:23) at async Command.processSubCommand (file:///home/rishi/code/robo.js/packages/robo/dist/cli/utils
/cli-handler.js:255:5) at async Command.processSubCommand (file:///home/rishi/code/robo.js/packages/robo/dist/cli/utils
/cli-handler.js:245:9) { errno: -2,
code: 'ENOENT',
syscall: 'stat',
path: '/home/rishi/code/robo.js/packages/robo/-v'
}
Node.js v22.9.0
This ENOENT
error seems unrelated to my changes since it’s happening on the main branch as well. Could you confirm if I’m missing something or if there’s another approach I should take? Your guidance would be greatly appreciated.
Thank you!
Hey ! it should work just fine on the main branch and latest version of Robo, just to confirm somethin, which OS are you running ?
Hey ! it should work just fine on the main branch and latest version of Robo, just to confirm somethin, which OS are you running ?
Ubuntu noble 24.04 x86_64
Hey sorry to get back to you so late, we cannot reproduce this issue at all on our environment with the main branch, tested on MacOS, Windows, and Linux too. would you be able to share your all Linux configuration where you are running the command please.
Summary:
This PR fixes issue #331, where single-value options in the CLI handler were incorrectly consuming positional arguments. The parser now correctly distinguishes between single-value and multi-value options, ensuring options like
-k
or--kit
consume only one argument, while options like--plugins
can accept multiple values.Key Changes:
Updated
Option
Interface:acceptsMultipleValues?: boolean
to indicate if an option accepts multiple values.Modified
option
Method:acceptsMultipleValues
parameter (default isfalse
).Adjusted
parseOptions
Method:--
is encountered.--
as a separator between options and positional arguments.Updated
processSubCommand
Method:parseOptions
to correctly handle positional arguments.Added Tests:
--
separator.Examples of Corrected Behavior:
Single-Value Option:
{ kit: 'activity' }
['myactivity']
Multi-Value Option with Separator:
{ plugins: ['@robojs/ai', '@robojs/sync'] }
['myactivity']
Impact:
Testing:
Notes:
--
to separate multi-value options from positional arguments when necessary.Thank you for reviewing this PR.