Skip to content

Add inline semicolon-separated list support for list-based CLI parameters#410

Merged
sensslen merged 14 commits into
mainfrom
copilot/add-allowed-licenses-argument
Feb 2, 2026
Merged

Add inline semicolon-separated list support for list-based CLI parameters#410
sensslen merged 14 commits into
mainfrom
copilot/add-allowed-licenses-argument

Conversation

Copy link
Copy Markdown

Copilot AI commented Jan 30, 2026

Implementation Plan: Support Inline List Arguments

  • Understand current architecture and identify list-based parameters
  • Create helper method to parse inline semicolon-separated values or JSON file
  • Update GetAllowedLicenses() to support both file and inline formats
  • Update GetIgnoredPackages() to support both file and inline formats
  • Update GetExcludedProjects() to support both file and inline formats
  • Update option descriptions to document the new inline format capability
  • Test the changes manually with CLI examples
  • Update documentation files (README and docs/)
  • Add error handling for invalid JSON files
  • Add disambiguation documentation for file vs inline detection
  • Run all tests - 3,280 tests passed successfully (9 new tests added)
  • Run security scan with CodeQL - no issues found
  • Comprehensive manual testing completed
  • Clean up build artifacts from repository
  • Clarify documentation that excluding test projects is just one example
  • Rebase changes on top of current main branch (with LicenseValidationHandler refactoring)
  • Successfully merged with main and applied changes to refactored code structure
  • Add comprehensive unit tests for ParseStringArrayOrFile functionality
  • Fix .NET Framework 4.7.2 compatibility issue with StringSplitOptions.TrimEntries
  • Rebase on latest main to have working test baseline
  • Update all option descriptions to complete sentences with explicit subjects and periods
Original prompt

This section details on the original issue you should resolve

<issue_title>AllowedLicenses as an argument instead a file</issue_title>
<issue_description>It would be great to have possibility to pass AllowedLicenses as an argument

nuget-license -i . -a "Apache-2.0;MIT;MIT AND BSD-3-Clause;IDPL;BSD-2-Clause;BSD-3-Clause;MS-EULA"

instead of a file

nuget-license -i . -a allowed_licenses.json

file content:

["Apache-2.0", "MIT", "MIT AND BSD-3-Clause", "IDPL", "BSD-2-Clause", "BSD-3-Clause", "MS-EULA"]

What do you think? </issue_description>

Comments on the Issue (you are @copilot in this section)

@sensslen Hi @Marusyk this is not a planned feature. Feel free to work on a PR that implements this feature though.

I'm more than happy to review and provide feedback for any improvement.

If you plan to work on that. Can you please consider adding this feature to other list based parameters as well so that the usage of the tool stays as consistent as possible.</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Summary by CodeRabbit

  • New Features

    • Command options now accept either a JSON file or an inline semicolon-separated list for allowed licenses, ignored packages, and excluded projects (automatic format detection).
  • Documentation

    • Expanded help and docs with examples, quoting guidance, format-detection notes, and clarified input formats and wildcard guidance.
  • Tests

    • Added extensive tests covering dual input formats, error cases, and combined option scenarios.
  • Chores

    • Added .nuget/ to repository ignore rules.

Copilot AI and others added 3 commits January 30, 2026 09:55
Co-authored-by: sensslen <3428860+sensslen@users.noreply.github.com>
Co-authored-by: sensslen <3428860+sensslen@users.noreply.github.com>
Co-authored-by: sensslen <3428860+sensslen@users.noreply.github.com>
Comment thread docs/exclude-projects-json.md Outdated
Copilot AI and others added 2 commits January 30, 2026 10:05
Co-authored-by: sensslen <3428860+sensslen@users.noreply.github.com>
Co-authored-by: sensslen <3428860+sensslen@users.noreply.github.com>
Copilot AI changed the title [WIP] Add AllowedLicenses as an argument instead of a file Add inline semicolon-separated list support for list-based CLI parameters Jan 30, 2026
Copilot AI requested a review from sensslen January 30, 2026 10:07
@sensslen
Copy link
Copy Markdown
Owner

sensslen commented Feb 2, 2026

@copilot rework these changes on top of current main

Copilot AI and others added 2 commits February 2, 2026 10:47
Co-authored-by: sensslen <3428860+sensslen@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Feb 2, 2026

@copilot rework these changes on top of current main

Rebased all changes on top of current main branch. The changes have been adapted to work with the new refactored code structure (LicenseValidationHandler and CommandLineOptions). All tests pass (commit 4cfac79).

@sensslen
Copy link
Copy Markdown
Owner

sensslen commented Feb 2, 2026

@copilot now make sure to add the necessary tests for the changes - also make sure to rebase again to have a working set of tests to compare against

Copilot AI and others added 2 commits February 2, 2026 11:09
Co-authored-by: sensslen <3428860+sensslen@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Feb 2, 2026

@copilot now make sure to add the necessary tests for the changes - also make sure to rebase again to have a working set of tests to compare against

Added 9 comprehensive tests for the inline list argument parsing functionality and rebased on latest main (commit 87fd970). Tests cover:

  • Inline semicolon-separated lists for all three parameters (AllowedLicenses, IgnoredPackages, ExcludedProjects)
  • Invalid JSON error handling
  • Null JSON error handling
  • Empty list handling
  • Whitespace trimming

Also fixed .NET Framework 4.7.2 compatibility issue. All 3,280 tests pass.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 2, 2026

Walkthrough

This pull request extends the command-line interface to accept dual input formats for three options: -a/--allowed-license-types, -ignore/--ignored-packages, and --exclude-projects-matching. Each option now accepts either a file path referencing a JSON array or an inline semicolon-separated list. The implementation adds a ParseStringArrayOrFile() helper method in LicenseValidationHandler.cs to automatically detect and parse both formats. Documentation files and help text are updated with examples for both methods. Comprehensive test coverage is added, and .nuget/ is added to .gitignore.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding inline semicolon-separated list support for CLI parameters, which is the core feature implemented across the codebase.
Linked Issues check ✅ Passed The PR fully implements issue #162 requirements: AllowedLicenses now accepts inline semicolon-separated values as an alternative to JSON files, with the same capability extended to other list-based parameters for consistency.
Out of Scope Changes check ✅ Passed All changes are scope-aligned: .gitignore addition is minor maintenance, documentation updates explain the new feature, LicenseValidationHandler implements the parsing helper, Program.cs updates option descriptions, and tests cover the new functionality.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch copilot/add-allowed-licenses-argument

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sensslen
Copy link
Copy Markdown
Owner

sensslen commented Feb 2, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 2, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@README.md`:
- Around line 61-70: Update the README option descriptions for the flags (-a /
--allowed-license-types, -ignore / --ignored-packages, -mapping /
--licenseurl-to-license-mappings, -file-mapping /
--licensefile-to-license-mappings, -override / --override-package-information,
-d / --license-information-download-location, -o / --output, -err /
--error-only, -include-ignored / --include-ignored-packages, -exclude-projects /
--exclude-projects-matching) so each description is a complete sentence with an
explicit subject and ends with a period; for example change fragments like
"Allowed license types. Can be either..." into full sentences such as "Specifies
allowed license types. You can provide a JSON file..."; apply the same style to
the ignored-packages, mapping, file-mapping, override, download-location,
output, error-only, include-ignored-packages, and exclude-projects descriptions.

In `@src/NuGetLicense/LicenseValidationHandler.cs`:
- Around line 217-219: The ArgumentException thrown in
LicenseValidationHandler.cs (the ternary return that reads inputJsonFile via
_fileSystem.File.ReadAllText and currently throws "Please provide an input file
using --input or --input-file-json") references a non-existent CLI flag; update
the exception message to mention the correct flag name "--json-input" (e.g.,
"Please provide an input file using --json-input") so the guidance from the
throw in that method matches the actual CLI option.
- Around line 173-180: The split-and-trim logic for inline values currently
returns entries that become empty after trimming; update the handling in
LicenseValidationHandler (the block that splits 'value' into 'parts') to remove
any entries that are empty or whitespace-only after Trim before returning. After
trimming each element of 'parts', filter out entries where
string.IsNullOrEmpty(parts[i]) (or use an equivalent Where/FindAll on the
trimmed values) so the returned array contains only non-empty
license/package/project tokens.
🧹 Nitpick comments (2)
docs/ignored-packages-json.md (2)

5-5: Consider rephrasing for improved clarity.

The current phrasing "Even though packages are ignored" could be more natural. Consider:

-**Note:** Even though packages are ignored, their transitive dependencies are not ignored unless explicitly listed.
+**Note:** When packages are ignored, their transitive dependencies are not ignored unless explicitly listed.

or

-**Note:** Even though packages are ignored, their transitive dependencies are not ignored unless explicitly listed.
+**Note:** Ignoring a package does not ignore its transitive dependencies unless they are explicitly listed.

11-27: Consider documenting error handling and file path behavior.

The JSON file section would benefit from clarifying:

  1. What happens when the JSON file contains invalid JSON
  2. Whether relative and absolute file paths are supported

Suggested addition after line 21:

The JSON file must contain a valid JSON array. If the file contains invalid JSON, the tool will report an error and exit.

File paths can be relative (to the current directory) or absolute.

This aligns with the PR objective to document error handling for invalid JSON.

Comment thread README.md Outdated
Comment thread src/NuGetLicense/LicenseValidationHandler.cs Outdated
Comment thread src/NuGetLicense/LicenseValidationHandler.cs Outdated
sensslen and others added 2 commits February 2, 2026 13:42
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@sensslen
Copy link
Copy Markdown
Owner

sensslen commented Feb 2, 2026

@copilot In @README.md around lines 61 - 70, Update the README option descriptions for
the flags (-a / --allowed-license-types, -ignore / --ignored-packages, -mapping
/ --licenseurl-to-license-mappings, -file-mapping /
--licensefile-to-license-mappings, -override / --override-package-information,
-d / --license-information-download-location, -o / --output, -err /
--error-only, -include-ignored / --include-ignored-packages, -exclude-projects /
--exclude-projects-matching) so each description is a complete sentence with an
explicit subject and ends with a period; for example change fragments like
"Allowed license types. Can be either..." into full sentences such as "Specifies
allowed license types. You can provide a JSON file..."; apply the same style to
the ignored-packages, mapping, file-mapping, override, download-location,
output, error-only, include-ignored-packages, and exclude-projects descriptions.

Be sure to also update the help texts exposed by the code

Co-authored-by: sensslen <3428860+sensslen@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Feb 2, 2026

@copilot In @README.md around lines 61 - 70, Update the README option descriptions for
the flags (-a / --allowed-license-types, -ignore / --ignored-packages, -mapping
/ --licenseurl-to-license-map...

Updated all option descriptions in both README.md and Program.cs to use complete sentences with explicit subjects and periods (commit 068d349).

Changes include:

  • README.md: Updated 10 option descriptions (lines 61-70)
  • Program.cs: Updated corresponding help texts for all options

Example transformation:

  • Before: "Allowed license types. Can be either..."
  • After: "Specifies allowed license types. You can provide either..."

All descriptions now follow consistent style with explicit subjects ("Specifies", "When set") and end with periods.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Feb 2, 2026

@sensslen
Copy link
Copy Markdown
Owner

sensslen commented Feb 2, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 2, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AllowedLicenses as an argument instead a file

2 participants