Skip to content

refactor: migrate from citty to node's built-in parseArgs#1971

Merged
IWANABETHATGUY merged 1 commit intorolldown:mainfrom
ikkz:feat/migrate-cli
Aug 13, 2024
Merged

refactor: migrate from citty to node's built-in parseArgs#1971
IWANABETHATGUY merged 1 commit intorolldown:mainfrom
ikkz:feat/migrate-cli

Conversation

@ikkz
Copy link
Copy Markdown
Contributor

@ikkz ikkz commented Aug 13, 2024

resolves #1954
resolves #1852

@netlify
Copy link
Copy Markdown

netlify bot commented Aug 13, 2024

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 5ac66b2
🔍 Latest deploy log https://app.netlify.com/sites/rolldown-rs/deploys/66bb2e2008bf0b00089e5737

@ikkz ikkz changed the title refact: migrate from citty to node's built-in parseArgs refactor: migrate from citty to node's built-in parseArgs Aug 13, 2024
@ikkz
Copy link
Copy Markdown
Contributor Author

ikkz commented Aug 13, 2024

Usage output and the current error output of #1852

image

Copy link
Copy Markdown
Contributor

@7086cmd 7086cmd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, and I will take care of matters pertaining to arguments in #1963. cc @IWANABETHATGUY.

Comment on lines +13 to +16
// We need to support both `rolldown -c` and `rolldown -c rolldown.config.js`,
// the value of the option could be either a boolean or a string in this case,
// so `strict` needs to be set to `false`
strict: false,
Copy link
Copy Markdown
Contributor

@7086cmd 7086cmd Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, it should be false. By the way, I wonder if we should specify the rolldown.config.js file or move it to the constants file (as it may be considered hardcoding if I remove the “constants” file.).

Additionally, I do not believe the automatically ignored parameter is elegant. Once the API becomes stable and independent, I think we should look into a better way to separate the default configuration or the configuration file that’s been specified 🤔.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, it should be false. By the way, I wonder if we should specify the rolldown.config.js file or move it to the constants file (as it may be considered hardcoding if I remove the “constants” file.).

It should be fine to keep it in constants.ts, as there might be some default values and so on for the CLI in the future.

Additionally, I do not believe the automatically ignored parameter is elegant. Once the API becomes stable and independent, I think we should look into a better way to separate the default configuration or the configuration file that’s been specified 🤔.

Perhaps when the user specifies both the config option and other options, we could log a message to inform them that we will ignore the other options?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be fine to keep it in constants.ts, as there might be some default values and so on for the CLI in the future.

Ok.

Perhaps when the user specifies both the config option and other options, we could log a message to inform them that we will ignore the other options?

I'll do it in #1963.

} from '../../package.json' assert { type: 'json' }
import { showHelp } from './commands/help'
import { DEFAULT_CONFIG_FILENAME } from './constants'
import { CLI_OPTIONS } from './options'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value should not be static when the automatically generated arguments are implemented, so I suggest using the camelCase method instead of the UPPER SNAKE_CASE method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this PR, the value is still static; you can change it to camelCase in your subsequent PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see.


const HELP_TEMPLATE = `rolldown version ${version}

${description}
Copy link
Copy Markdown
Member

@IWANABETHATGUY IWANABETHATGUY Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API. (rolldown v0.12.2)

Can you keep the layout as before?

image

Copy link
Copy Markdown
Contributor Author

@ikkz ikkz Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current output and before:
image

}
return cyan(optionStr.padEnd(30)) + description
})
.join('\n'),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an indentation for each option ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Also we should fix the wrong indentation before

Copy link
Copy Markdown
Contributor Author

@ikkz ikkz Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, two spaces are added bofore each option

@ikkz ikkz force-pushed the feat/migrate-cli branch from 79f3af9 to 9b27ffc Compare August 13, 2024 09:50
@IWANABETHATGUY IWANABETHATGUY added this pull request to the merge queue Aug 13, 2024
Merged via the queue into rolldown:main with commit cc0c7f7 Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

replace citty with builtin node:parseArgs to parse command line args. [Bug]: Should not emit twice for the same diagnostic

3 participants