-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support filter by if a key is expired (#55)
Signed-off-by: catcherwong <catcher_hwq@outlook.com>
- Loading branch information
1 parent
df3cfc4
commit cee47c6
Showing
9 changed files
with
427 additions
and
370 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<Project> | ||
<PropertyGroup> | ||
|
||
<RDBParserVersion>0.7.0</RDBParserVersion> | ||
<RDBCliVersion>0.8.2</RDBCliVersion> | ||
<RDBParserVersion>0.7.1</RDBParserVersion> | ||
<RDBCliVersion>0.8.3</RDBCliVersion> | ||
|
||
</PropertyGroup> | ||
</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,15 @@ | ||
using System.CommandLine; | ||
|
||
namespace RDBCli.Commands | ||
{ | ||
internal static class CommonCLIArguments | ||
{ | ||
public static Argument<string> FileArgument() | ||
{ | ||
Argument<string> arg = | ||
new Argument<string>("file", "The path of rdb file."); | ||
|
||
return arg; | ||
} | ||
} | ||
} |
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,176 @@ | ||
using System.Collections.Generic; | ||
using System.CommandLine; | ||
|
||
namespace RDBCli.Commands | ||
{ | ||
internal static class CommonCLIOptions | ||
{ | ||
public static Option<string> OutputOption() | ||
{ | ||
Option<string> option = | ||
new Option<string>( | ||
aliases: new string[] { "--output", "-o" }, | ||
description: "The output path of parsing result.") | ||
.LegalFilePathsOnly(); | ||
|
||
return option; | ||
} | ||
|
||
public static Option<string> OutputTypeOption() | ||
{ | ||
Option<string> option = | ||
new Option<string>( | ||
aliases: new string[] { "--output-type", "-ot" }, | ||
getDefaultValue: () => "json", | ||
description: "The output type of parsing result.") | ||
.FromAmong("json", "html", "csv"); | ||
|
||
return option; | ||
} | ||
|
||
public static Option<int> TopPrefixCountOption() | ||
{ | ||
Option<int> option = | ||
new Option<int>( | ||
aliases: new string[] { "--top-prefixes", "-tp" }, | ||
getDefaultValue: () => 50, | ||
description: "The number of top key prefixes."); | ||
|
||
option.AddValidator(x => | ||
{ | ||
var c = x.GetValueOrDefault<int>(); | ||
if (c > 200) x.ErrorMessage = "The number can not greater than 200!!"; | ||
}); | ||
|
||
return option; | ||
} | ||
|
||
public static Option<int> TopBigKeyCountOption() | ||
{ | ||
Option<int> option = | ||
new Option<int>( | ||
aliases: new string[] { "--top-bigkeys", "-tb" }, | ||
getDefaultValue: () => 50, | ||
description: "The number of top big keys."); | ||
|
||
option.AddValidator(x => | ||
{ | ||
var c = x.GetValueOrDefault<int>(); | ||
if (c > 200) x.ErrorMessage = "The number can not greater than 200!!"; | ||
}); | ||
|
||
return option; | ||
} | ||
|
||
public static Option<List<int>> DBsOption() | ||
{ | ||
Option<List<int>> option = | ||
new Option<List<int>>( | ||
aliases: new string[] { "--db" }, | ||
description: "The filter of redis databases."); | ||
|
||
return option; | ||
} | ||
|
||
public static Option<List<string>> TypesOption() | ||
{ | ||
Option<List<string>> option = | ||
new Option<List<string>>( | ||
aliases: new string[] { "--type" }, | ||
description: "The filter of redis types.") | ||
.FromAmong("string", "list", "set", "sortedset", "hash", "module", "stream"); | ||
|
||
return option; | ||
} | ||
|
||
public static Option<List<string>> KeyPrefixesOption() | ||
{ | ||
Option<List<string>> option = | ||
new Option<List<string>>( | ||
aliases: new string[] { "--key-prefix" }, | ||
description: "The filter of redis key prefix."); | ||
|
||
return option; | ||
} | ||
|
||
public static Option<bool?> KeySuffixEnableOption() | ||
{ | ||
Option<bool?> option = | ||
new Option<bool?>( | ||
aliases: new string[] { "--key-suffix-enable" }, | ||
description: "Use the key suffix as the key prefix."); | ||
|
||
return option; | ||
} | ||
|
||
public static Option<string> SeparatorsOption() | ||
{ | ||
Option<string> option = | ||
new Option<string>( | ||
aliases: new string[] { "--separators" }, | ||
description: "The separators of redis key prefix."); | ||
|
||
return option; | ||
} | ||
|
||
public static Option<int> SepPrefixCountOption() | ||
{ | ||
Option<int> option = | ||
new Option<int>( | ||
aliases: new string[] { "--sep-count" }, | ||
description: "The count of separating a key to prefix."); | ||
|
||
return option; | ||
} | ||
|
||
public static Option<bool?> IsPermanentOption() | ||
{ | ||
Option<bool?> option = | ||
new Option<bool?>( | ||
aliases: new string[] { "--permanent" }, | ||
description: "Whether the key is permanent."); | ||
|
||
return option; | ||
} | ||
|
||
public static Option<bool?> IsExpiredOption() | ||
{ | ||
Option<bool?> option = | ||
new Option<bool?>( | ||
aliases: new string[] { "--expired" }, | ||
description: "Whether the key is expired."); | ||
|
||
return option; | ||
} | ||
|
||
public static Option<bool?> IsIgnoreFieldOfLargestElemOption() | ||
{ | ||
Option<bool?> option = | ||
new Option<bool?>( | ||
aliases: new string[] { "--ignore-fole" }, | ||
description: "Whether ignore the field of largest elem."); | ||
|
||
return option; | ||
} | ||
|
||
public static Option<ulong?> MinIdleOption() | ||
{ | ||
Option<ulong?> option = | ||
new Option<ulong?>( | ||
aliases: new string[] { "--min-idle" }, | ||
description: "The minimum idle time of the key(must lru policy)"); | ||
|
||
return option; | ||
} | ||
|
||
public static Option<int?> MinFreqOption() | ||
{ | ||
Option<int?> option = | ||
new Option<int?>( | ||
aliases: new string[] { "--min-freq" }, | ||
description: "The minimum frequency of the key(must lfu policy)"); | ||
|
||
return option; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.