Skip to content

Commit

Permalink
Add --machine-readable option to 'ckan compare'
Browse files Browse the repository at this point in the history
  • Loading branch information
DasSkelett committed Jun 19, 2019
1 parent c07d880 commit d95ecbd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Cmdline/Action/Compare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ public int RunCommand(object rawOptions)
var rightVersion = new ModuleVersion(options.Right);

int compareResult = leftVersion.CompareTo(rightVersion);
if (compareResult == 0)

if (options.machine_readable)
{
user.RaiseMessage(compareResult.ToString());
}
else if (compareResult == 0)
{
user.RaiseMessage(
"\"{0}\" and \"{1}\" are the same versions.", leftVersion, rightVersion);
Expand Down
3 changes: 3 additions & 0 deletions Cmdline/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,9 @@ internal class SearchOptions : InstanceSpecificOptions

internal class CompareOptions : CommonOptions
{
[Option("machine-readable", HelpText = "Output in a machine readable format: -1, 0 or 1")]
public bool machine_readable { get; set;}

[ValueOption(0)] public string Left { get; set; }
[ValueOption(1)] public string Right { get; set; }
}
Expand Down

0 comments on commit d95ecbd

Please sign in to comment.