Skip to content

Commit

Permalink
MergeCommand: rename --input-files-list0 to --input-files-nul-list (w…
Browse files Browse the repository at this point in the history
…ork around stupid Options parser)

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jul 19, 2023
1 parent 064715e commit 89499f5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Usage:
Options:
--input-files <input-files> Input BOM filenames (separate filenames with a space).
--input-files-list <input-files-list-files> One or more text file(s) with input BOM filenames (one per line).
--input-files-list0 <input-files-list-files> One or more text-like file(s) with input BOM filenames (separated by 0x00 characters).
--input-files-nul-list <input-files-list-files> One or more text-like file(s) with input BOM filenames (separated by 0x00 characters).
--output-file <output-file> Output BOM filename, will write to stdout if no value provided.
--input-format <autodetect|json|protobuf|xml> Specify input file format.
--output-format <autodetect|json|protobuf|xml> Specify output file format.
Expand All @@ -211,7 +211,7 @@ The `--input-files-list` option can be useful if you have so many filenames to
merge that your shell interpreter command-line limit is exceeded if you list
them all as `--input-files`, or if your path names have spaces.

The related `--input-files-list0` is intended for lists prepared by commands
The related `--input-files-nul-list` is intended for lists prepared by commands
like `find ... -print0` and makes sense on filesystems where carriage-return
and/or line-feed characters may validly be present in a path name component.
Note: behavior with multi-byte encodings (Unicode family) where a 0x00 byte
Expand All @@ -220,9 +220,10 @@ can be part of a character may be undefined.
If you specify several of these options, the effective file lists will be
concatenated before the actual merge (first the individual `--input-files`,
then the contents of `--input-files-list`, and finally the contents of
`--input-files-list0`). If you have a document crafted to describe the root
of your product hierarchy tree, it is recommended to list it as the first
of individual `--input-files` (or otherwise on first line among used lists).
`--input-files-nul-list`). If you have a document crafted to describe the
root of your product hierarchy tree, it is recommended to list it as the
first of individual `--input-files` (or otherwise on first line among used
lists).

### Examples

Expand Down
10 changes: 5 additions & 5 deletions src/cyclonedx/Commands/MergeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static void Configure(RootCommand rootCommand)
var subCommand = new Command("merge", "Merge two or more BOMs");
subCommand.Add(new Option<List<string>>("--input-files", "Input BOM filenames (separate filenames with a space)."));
subCommand.Add(new Option<List<string>>("--input-files-list", "One or more text file(s) with input BOM filenames (one per line)."));
subCommand.Add(new Option<List<string>>("--input-files-list0", "One or more text-like file(s) with input BOM filenames (separated by 0x00 characters)."));
subCommand.Add(new Option<List<string>>("--input-files-nul-list", "One or more text-like file(s) with input BOM filenames (separated by 0x00 characters)."));
subCommand.Add(new Option<string>("--output-file", "Output BOM filename, will write to stdout if no value provided."));
subCommand.Add(new Option<CycloneDXBomFormat>("--input-format", "Specify input file format."));
subCommand.Add(new Option<CycloneDXBomFormat>("--output-format", "Specify output file format."));
Expand Down Expand Up @@ -91,11 +91,11 @@ public static async Task<int> Merge(MergeCommandOptions options)
}
}

if (options.InputFilesList0 != null)
if (options.InputFilesNulList != null)
{
ImmutableList<string> InputFilesList0 = options.InputFilesList0.ToImmutableList();
Console.WriteLine($"Got " + InputFilesList0.Count + " file(s) with NUL-separated actual input file names: ['" + string.Join("', '", InputFilesList0) + "']");
foreach (string OneInputFileList in InputFilesList0)
ImmutableList<string> InputFilesNulList = options.InputFilesNulList.ToImmutableList();
Console.WriteLine($"Got " + InputFilesNulList.Count + " file(s) with NUL-separated actual input file names: ['" + string.Join("', '", InputFilesNulList) + "']");
foreach (string OneInputFileList in InputFilesNulList)
{
Console.WriteLine($"Adding to input file list from " + OneInputFileList);
string[] lines = File.ReadAllText(OneInputFileList).Split('\0');
Expand Down
2 changes: 1 addition & 1 deletion src/cyclonedx/Commands/MergeCommandOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class MergeCommandOptions
{
public IList<string> InputFiles { get; set; }
public IList<string> InputFilesList { get; set; }
public IList<string> InputFilesList0 { get; set; }
public IList<string> InputFilesNulList { get; set; }
public string OutputFile { get; set; }
public CycloneDXBomFormat InputFormat { get; set; }
public CycloneDXBomFormat OutputFormat { get; set; }
Expand Down

0 comments on commit 89499f5

Please sign in to comment.