Skip to content

Commit

Permalink
[WIP] Draft the commandline params
Browse files Browse the repository at this point in the history
  • Loading branch information
celeron533 committed Jul 14, 2024
1 parent 1ae4b81 commit 6b9edfc
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 1 deletion.
8 changes: 7 additions & 1 deletion DicomGrep.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DicomGrep", "DicomGrep\Dico
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DicomGrepTests", "DicomGrepTests\DicomGrepTests.csproj", "{C26AA249-3A83-4B9A-9672-633AFE3081E4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DicomGrepCore", "DicomGrepCore\DicomGrepCore.csproj", "{572F835B-6298-4075-A1E3-50675927CCF1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DicomGrepCore", "DicomGrepCore\DicomGrepCore.csproj", "{572F835B-6298-4075-A1E3-50675927CCF1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DicomGrepCli", "DicomGrepCli\DicomGrepCli.csproj", "{2404C580-7A56-4918-AB08-D9AF9E48ED15}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -27,6 +29,10 @@ Global
{572F835B-6298-4075-A1E3-50675927CCF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{572F835B-6298-4075-A1E3-50675927CCF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{572F835B-6298-4075-A1E3-50675927CCF1}.Release|Any CPU.Build.0 = Release|Any CPU
{2404C580-7A56-4918-AB08-D9AF9E48ED15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2404C580-7A56-4918-AB08-D9AF9E48ED15}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2404C580-7A56-4918-AB08-D9AF9E48ED15}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2404C580-7A56-4918-AB08-D9AF9E48ED15}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
16 changes: 16 additions & 0 deletions DicomGrepCli/DicomGrepCli.csproj
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>
88 changes: 88 additions & 0 deletions DicomGrepCli/Program.cs
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
}
}

0 comments on commit 6b9edfc

Please sign in to comment.