refactor and introduce tests for npm & pypi (#79)

* refactor and introduce tests for npm & pypi

* refactor and introduce tests for npm & pypi

* add skip intermediate flags test case

* fix tests

---------

Co-authored-by: Abhisek Datta <abhisek.datta@gmail.com>
This commit is contained in:
Sahil Bansal
2025-12-08 17:30:29 +00:00
committed by GitHub
co-authored by Abhisek Datta
parent 2be1e5f009
commit a8723cd680
4 changed files with 305 additions and 163 deletions
+2 -2
View File
@@ -103,7 +103,7 @@ func NewPipCommandParser(config PypiPackageManagerConfig) pypiCommandParser {
func (p *pipCommandParser) ParseCommand(args []string) (*ParsedCommand, error) {
// Remove 'pip' if it's the first argument
if len(args) > 0 && args[0] == "pip" {
if len(args) > 0 && (args[0] == "pip" || args[0] == "pip3") {
args = args[1:]
}
@@ -130,7 +130,7 @@ func (p *pipCommandParser) ParseCommand(args []string) (*ParsedCommand, error) {
// Extract arguments after the install command
installArgs := args[installCmdIndex+1:]
flagSet := pflag.NewFlagSet("pip", pflag.ContinueOnError)
flagSet := pflag.NewFlagSet(p.config.CommandName, pflag.ContinueOnError)
flagSet.SetOutput(io.Discard)
flagSet.ParseErrorsWhitelist.UnknownFlags = true