Skip to content

Commit

Permalink
implement help
Browse files Browse the repository at this point in the history
  • Loading branch information
rushfive committed Mar 22, 2019
1 parent f69025e commit 2580a03
Show file tree
Hide file tree
Showing 11 changed files with 269 additions and 158 deletions.
59 changes: 31 additions & 28 deletions CLI/R5.FFDB.CLI/Commands/AddStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,47 @@ public class RunInfo : RunInfoBase
public WeekInfo? Week { get; set; }
}

internal static Command<RunInfo> Command = new Command<RunInfo>
internal static Command<RunInfo> GetCommand()
{
Key = _commandKey,
SubCommands =
var command = new Command<RunInfo>
{
new SubCommand<RunInfo>
Key = _commandKey,
SubCommands =
{
Key = "missing"
},
new SubCommand<RunInfo>
{
Key = "week",
Arguments =
new SubCommand<RunInfo>
{
new PropertyArgument<RunInfo, WeekInfo?>
{
Property = ri => ri.Week,
HelpToken = "<week>"
}
Key = "missing"
},
Options =
new SubCommand<RunInfo>
{
new Option<RunInfo, bool>
Key = "week",
Arguments =
{
Key = "skip-roster-fetch | s",
Property = ri => ri.SkipRosterFetch
new PropertyArgument<RunInfo, WeekInfo?>
{
Property = ri => ri.Week,
HelpToken = "<week>"
}
}
}
}
},
GlobalOptions =
{
new Option<RunInfo, string>
},
GlobalOptions =
{
Key = "config | c",
Property = ri => ri.ConfigFilePath
new Option<RunInfo, bool>
{
Key = "save-to-disk",
Property = ri => ri.SaveToDisk
},
new Option<RunInfo, bool>
{
Key = "save-src-files",
Property = ri => ri.SaveOriginalSourceFiles
}
}
}
};
};

RunInfoBase.AddCommonOptions(command);
return command;
}
}
}
69 changes: 35 additions & 34 deletions CLI/R5.FFDB.CLI/Commands/InitialSetup.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
//using R5.RunInfoBuilder;
//using System;
//using System.Collections.Generic;
//using System.Text;
using R5.RunInfoBuilder;
using System;
using System.Collections.Generic;
using System.Text;

//namespace R5.FFDB.CLI.Commands
//{
// // ffdb setup --force|f --config|c=path\to\config.json
// public static class InitialSetup
// {
// private const string _commandKey = "setup";
namespace R5.FFDB.CLI.Commands
{
// ffdb setup --skip-stats|s --config|c=path\to\config.json
public static class InitialSetup
{
private const string _commandKey = "setup";

// public class RunInfo : RunInfoBase
// {
// public override string CommandKey => _commandKey;
// public bool ForceReinitialize { get; set; }
// }
public class RunInfo : RunInfoBase
{
public override string CommandKey => _commandKey;
public bool SkipAddingStats { get; set; }
}

// internal static Command<RunInfo> Command = new Command<RunInfo>
// {
// Key = _commandKey,
// Options =
// {
// new Option<RunInfo, bool>
// {
// Key = "force | f",
// Property = ri => ri.ForceReinitialize
// },
// new Option<RunInfo, string>
// {
// Key = "config | c",
// Property = ri => ri.ConfigFilePath
// }
// }
// };
// }
//}
internal static Command<RunInfo> GetCommand()
{
var command = new Command<RunInfo>
{
Key = _commandKey,
Options =
{
new Option<RunInfo, bool>
{
Key = "skip-stats | s",
Property = ri => ri.SkipAddingStats
}
}
};

RunInfoBase.AddCommonOptions(command);
return command;
}
}
}
37 changes: 36 additions & 1 deletion CLI/R5.FFDB.CLI/Commands/RunInfoBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using R5.RunInfoBuilder;
using System;
using System.Collections.Generic;
using System.Text;

Expand All @@ -7,9 +8,43 @@ namespace R5.FFDB.CLI.Commands
public abstract class RunInfoBase
{
public abstract string CommandKey { get; }

public string ConfigFilePath { get; set; }
public bool SkipRosterFetch { get; set; }
public bool SaveToDisk { get; set; }
public bool SaveOriginalSourceFiles { get; set; }

public static void AddCommonOptions<T>(Command<T> command)
where T : RunInfoBase
{
if (command.GlobalOptions == null)
{
command.GlobalOptions = new List<OptionBase<T>>();
}

command.GlobalOptions.Add(new Option<T, string>
{
Key = "config | c",
Property = ri => ri.ConfigFilePath
});

command.GlobalOptions.Add(new Option<T, bool>
{
Key = "skip-roster",
Property = ri => ri.SkipRosterFetch
});

//command.GlobalOptions.Add(new Option<T, bool>
//{
// Key = "save-to-disk",
// Property = ri => ri.SaveToDisk
//});

//command.GlobalOptions.Add(new Option<T, bool>
//{
// Key = "save-src-files",
// Property = ri => ri.SaveOriginalSourceFiles
//});
}
}
}
52 changes: 0 additions & 52 deletions CLI/R5.FFDB.CLI/Commands/UpdatePlayers.cs

This file was deleted.

31 changes: 31 additions & 0 deletions CLI/R5.FFDB.CLI/Commands/UpdateRosteredPlayers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using R5.FFDB.Core.Models;
using R5.RunInfoBuilder;
using System;
using System.Collections.Generic;
using System.Text;

namespace R5.FFDB.CLI.Commands
{
// ffdb update-players rostered
// ffdb update-players all
public static class UpdateRosteredPlayers
{
private const string _commandKey = "update-players";

public class RunInfo : RunInfoBase
{
public override string CommandKey => _commandKey;
}

internal static Command<RunInfo> GetCommand()
{
var command = new Command<RunInfo>
{
Key = _commandKey
};

RunInfoBase.AddCommonOptions(command);
return command;
}
}
}
18 changes: 8 additions & 10 deletions CLI/R5.FFDB.CLI/Commands/UpdateRosters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ public class RunInfo : RunInfoBase
public override string CommandKey => _commandKey;
}

internal static Command<RunInfo> Command = new Command<RunInfo>
internal static Command<RunInfo> GetCommand()
{
Key = _commandKey,
Options =
var command = new Command<RunInfo>
{
new Option<RunInfo, string>
{
Key = "config | c",
Property = ri => ri.ConfigFilePath
}
}
};
Key = _commandKey
};

RunInfoBase.AddCommonOptions(command);
return command;
}
}
}
18 changes: 8 additions & 10 deletions CLI/R5.FFDB.CLI/Commands/ViewUpdated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ public class RunInfo : RunInfoBase
public override string CommandKey => _commandKey;
}

internal static Command<RunInfo> Command = new Command<RunInfo>
internal static Command<RunInfo> GetCommand()
{
Key = _commandKey,
Options =
var command = new Command<RunInfo>
{
new Option<RunInfo, string>
{
Key = "config | c",
Property = ri => ri.ConfigFilePath
}
}
};
Key = _commandKey
};

RunInfoBase.AddCommonOptions(command);
return command;
}
}
}
Loading

0 comments on commit 2580a03

Please sign in to comment.