-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ae4b81
commit 6b9edfc
Showing
3 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<PublishAot>true</PublishAot> | ||
<InvariantGlobalization>true</InvariantGlobalization> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using System.CommandLine; | ||
using System.CommandLine.Invocation; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace DicomGrepCli | ||
{ | ||
internal class Program | ||
{ | ||
static async Task<int> Main(string[] args) | ||
{ | ||
var rootCommand = new RootCommand("DicomGrep Command Line Interface"); | ||
|
||
var versionOption = new Option<bool>( | ||
name: "--version", | ||
description: "Show version information" | ||
); | ||
versionOption.AddAlias("-V"); | ||
rootCommand.AddOption(versionOption); | ||
|
||
#region lookup options | ||
// once see the lookup options, do not execute any search | ||
var lookupOption = new Option<LookupIn>( | ||
name: "--lookup", | ||
description: "lookup the Dictionary or SOPClass UID" | ||
); | ||
lookupOption.AddAlias("-l"); | ||
rootCommand.AddOption(lookupOption); | ||
#endregion | ||
|
||
#region search options | ||
var folderOption = new Option<string>( | ||
name: "--dir", | ||
description: "search in this directory" | ||
); | ||
rootCommand.AddOption(folderOption); | ||
|
||
//-r, --recursive. As well as GREP | ||
var recursiveOption = new Option<bool>( | ||
name: "--recursive", | ||
description: "search in subdirectories" | ||
); | ||
recursiveOption.AddAlias("-r"); | ||
rootCommand.AddOption(recursiveOption); | ||
|
||
//-i, --ignore-case. As well as GREP | ||
var ignoreCaseOption = new Option<bool>( | ||
name: "--ignore-case", | ||
description: "ignore case" | ||
); | ||
ignoreCaseOption.AddAlias("-i"); | ||
rootCommand.AddOption(ignoreCaseOption); | ||
|
||
//-F, --fixed-strings. As well as GREP | ||
//-e PATTERNS, --regexp = PATTERNS. As well as GREP | ||
//-c, --count. As well as GREP | ||
|
||
//-t, --tag. DICOM Tag | ||
var tagOption = new Option<string>( | ||
name: "--tag", | ||
description: "DICOM Tag" | ||
); | ||
tagOption.AddAlias("-t"); | ||
rootCommand.AddOption(tagOption); | ||
|
||
//-v, --value. DICOM Tag Value | ||
var valueOption = new Option<string>( | ||
name: "--value", | ||
description: "DICOM Tag Value" | ||
); | ||
valueOption.AddAlias("-v"); | ||
rootCommand.AddOption(valueOption); | ||
|
||
|
||
#endregion search options | ||
|
||
|
||
return await rootCommand.InvokeAsync(args); | ||
} | ||
|
||
|
||
} | ||
|
||
enum LookupIn | ||
{ | ||
DICT = 0, | ||
SOP | ||
} | ||
} |