-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Agentew04/dev
Accept CLI support branch
- Loading branch information
Showing
9 changed files
with
669 additions
and
577 deletions.
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,27 @@ | ||
using System.Linq; | ||
|
||
namespace SafeFolder; | ||
|
||
public record Flag(string FullName, string? CompactName); | ||
|
||
public static class CliUtils { | ||
public static bool hasFlag(string[] args, Flag flag) { | ||
string full = "--" + flag.FullName; | ||
string? small = flag.CompactName is not null ? "-" + flag.CompactName : null; | ||
return args.Any(x => x == full || ( small is not null && x == small )); | ||
} | ||
|
||
public static string? getFlagValue(string[] args, Flag flag) { | ||
string full = "--" + flag.FullName; | ||
string? small = flag.CompactName is not null ? "-" + flag.CompactName : null; | ||
|
||
for (var i = 0; i < args.Length; i++) { | ||
if (args[i] != full && args[i] != small) | ||
continue; | ||
if (i + 1 < args.Length) { | ||
return args[i + 1]; | ||
} | ||
} | ||
return null; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.