2017-02-02 15:08:21 -08:00
using System.Collections.Generic ;
2017-05-04 02:41:11 -07:00
using SabreTools.Library.Data ;
using SabreTools.Library.Help ;
2017-02-02 15:08:21 -08:00
namespace RombaSharp
{
public partial class RombaSharp
{
2018-01-27 15:09:31 -08:00
#region Private Flag features
private static Feature fixdatOnlyFlag
{
get
{
return new Feature (
"fixdatOnly" ,
"-fixdatOnly" ,
"only fix dats and don't generate torrentzips" ,
FeatureType . Flag ) ;
}
}
private static Feature logOnlyFlag
{
get
{
return new Feature (
"log-only" ,
"-log-only" ,
"Only write out actions to log" ,
FeatureType . Flag ) ;
}
} // Unique to RombaSharp
private static Feature noDbFlag
{
get
{
return new Feature (
"no-db" ,
"-no-db" ,
"archive into depot but do not touch DB index and ignore only-needed flag" ,
FeatureType . Flag ) ;
}
}
private static Feature onlyNeededFlag
{
get
{
return new Feature (
"only-needed" ,
"-only-needed" ,
"only archive ROM files actually referenced by DAT files from the DAT index" ,
FeatureType . Flag ) ;
}
}
private static Feature skipInitialScanFlag
{
get
{
return new Feature (
"skip-initial-scan" ,
"-skip-initial-scan" ,
"skip the initial scan of the files to determine amount of work" ,
FeatureType . Flag ) ;
}
}
private static Feature useGolangZipFlag
{
get
{
return new Feature (
"use-golang-zip" ,
"-use-golang-zip" ,
"use go zip implementation instead of zlib" ,
FeatureType . Flag ) ;
}
}
#endregion
#region Private Int32 features
private static Feature include7ZipsInt32Input
{
get
{
return new Feature (
"include-7zips" ,
"-include-7zips" ,
"flag value == 1 means: add 7zip files themselves into the depot in addition to their contents, flag value > 1 means add 7zip files themselves but don't add content" ,
FeatureType . Int32 ) ;
}
}
private static Feature includeGZipsInt32Input
{
get
{
return new Feature (
"include-gzips" ,
"-include-gzips" ,
"flag value == 1 means: add gzip files themselves into the depot in addition to their contents, flag value > 1 means add gzip files themselves but don't add content" ,
FeatureType . Int32 ) ;
}
}
private static Feature includeZipsInt32Input
{
get
{
return new Feature (
"include-zips" ,
"-include-zips" ,
"flag value == 1 means: add zip files themselves into the depot in addition to their contents, flag value > 1 means add zip files themselves but don't add content" ,
FeatureType . Int32 ) ;
}
}
private static Feature subworkersInt32Input
{
get
{
return new Feature (
"subworkers" ,
"-subworkers" ,
"how many subworkers to launch for each worker" ,
FeatureType . Int32 ) ;
}
} // Defaults to Workers count in config
private static Feature workersInt32Input
{
get
{
return new Feature (
"workers" ,
"-workers" ,
"how many workers to launch for the job" ,
FeatureType . Int32 ) ;
}
} // Defaults to Workers count in config
#endregion
#region Private Int64 features
private static Feature sizeInt64Input
{
get
{
return new Feature (
"size" ,
"-size" ,
"size of the rom to lookup" ,
FeatureType . Int64 ) ;
}
}
#endregion
#region Private List < String > features
private static Feature datsListStringInput
{
get
{
return new Feature (
"dats" ,
"-dats" ,
"purge only roms declared in these dats" ,
FeatureType . List ) ;
}
}
private static Feature depotListStringInput
{
get
{
return new Feature (
"depot" ,
"-depot" ,
"work only on specified depot path" ,
FeatureType . List ) ;
}
}
#endregion
#region Private String features
private static Feature backupStringInput
{
get
{
return new Feature (
"backup" ,
"-backup" ,
"backup directory where backup files are moved to" ,
FeatureType . String ) ;
}
}
private static Feature descriptionStringInput
{
get
{
return new Feature (
"description" ,
"-description" ,
"description value in DAT header" ,
FeatureType . String ) ;
}
}
private static Feature missingSha1sStringInput
{
get
{
return new Feature (
"missingSha1s" ,
"-missingSha1s" ,
"write paths of dats with missing sha1s into this file" ,
FeatureType . String ) ;
}
}
private static Feature nameStringInput
{
get
{
return new Feature (
"name" ,
"-name" ,
"name value in DAT header" ,
FeatureType . String ) ;
}
}
private static Feature newStringInput
{
get
{
return new Feature (
"new" ,
"-new" ,
"new DAT file" ,
FeatureType . String ) ;
}
}
private static Feature oldStringInput
{
get
{
return new Feature (
"old" ,
"-old" ,
"old DAT file" ,
FeatureType . String ) ;
}
}
private static Feature outStringInput
{
get
{
return new Feature (
"out" ,
"-out" ,
"output file" ,
FeatureType . String ) ;
}
}
private static Feature resumeStringInput
{
get
{
return new Feature (
"resume" ,
"-resume" ,
"resume a previously interrupted operation from the specified path" ,
FeatureType . String ) ;
}
}
private static Feature sourceStringInput
{
get
{
return new Feature (
"source" ,
"-source" ,
"source directory" ,
FeatureType . String ) ;
}
}
#endregion
2017-02-02 15:08:21 -08:00
public static Help RetrieveHelp ( )
{
// Create and add the header to the Help object
string barrier = "-----------------------------------------" ;
2017-03-01 21:49:30 -08:00
List < string > helpHeader = new List < string > ( )
{
"RombaSharp - C# port of the Romba rom management tool" ,
barrier ,
"Usage: RombaSharp [option] [filename|dirname] ..." ,
""
} ;
2017-02-02 15:08:21 -08:00
Help help = new Help ( helpHeader ) ;
2018-01-27 15:09:31 -08:00
#region Help
2017-02-02 15:08:21 -08:00
Feature helpFeature = new Feature (
2018-01-23 15:55:04 -08:00
"Help" ,
2017-02-02 15:08:21 -08:00
new List < string > ( ) { "-?" , "-h" , "--help" } ,
"Show this help" ,
2018-01-27 15:09:31 -08:00
FeatureType . Flag ) ;
#endregion
#region Archive
2017-02-02 15:08:21 -08:00
Feature archive = new Feature (
2018-01-23 15:55:04 -08:00
"Archive" ,
2017-02-02 15:08:21 -08:00
"archive" ,
2018-01-27 15:09:31 -08:00
"Adds ROM files from the specified directories to the ROM archive." ,
2017-02-02 15:08:21 -08:00
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : @ "Adds ROM files from the specified directories to the ROM archive.
Traverses the specified directory trees looking for zip files and normal files .
Unpacked files will be stored as individual entries . Prior to unpacking a zip
file , the external SHA1 is checked against the DAT index .
If - only - needed is set , only those files are put in the ROM archive that
have a current entry in the DAT index . ");
archive . AddFeature ( onlyNeededFlag ) ;
archive . AddFeature ( resumeStringInput ) ;
archive . AddFeature ( includeZipsInt32Input ) ; // Defaults to 0
archive . AddFeature ( workersInt32Input ) ;
archive . AddFeature ( includeGZipsInt32Input ) ; // Defaults to 0
archive . AddFeature ( include7ZipsInt32Input ) ; // Defaults to 0
archive . AddFeature ( skipInitialScanFlag ) ;
archive . AddFeature ( useGolangZipFlag ) ;
archive . AddFeature ( noDbFlag ) ;
#endregion
#region Build
2017-02-02 15:08:21 -08:00
Feature build = new Feature (
2018-01-23 15:55:04 -08:00
"Build" ,
2017-02-02 15:08:21 -08:00
"build" ,
2018-01-27 15:09:31 -08:00
"For each specified DAT file it creates the torrentzip files." ,
2017-02-02 15:08:21 -08:00
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : @ "For each specified DAT file it creates the torrentzip files in the specified
output dir . The files will be placed in the specified location using a folder
structure according to the original DAT master directory tree structure . ");
build . AddFeature ( outStringInput ) ;
build . AddFeature ( fixdatOnlyFlag ) ;
build . AddFeature ( workersInt32Input ) ;
build . AddFeature ( subworkersInt32Input ) ;
#endregion
#region Cancel
Feature cancel = new Feature (
"Cancel" ,
"cancel" ,
"Cancels current long-running job" ,
2017-02-02 15:08:21 -08:00
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : @"Cancels current long-running job." ) ;
2017-02-02 15:08:21 -08:00
2018-01-27 15:09:31 -08:00
#endregion
#region DatStats
Feature datstats = new Feature (
"DatStats" ,
"datstats" ,
"Prints dat stats." ,
2017-02-02 15:08:21 -08:00
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : @"Print dat stats." ) ;
2017-02-02 15:08:21 -08:00
2018-01-27 15:09:31 -08:00
#endregion
#region DbStats
Feature dbstats = new Feature (
"DbStats" ,
"dbstats" ,
"Prints db stats." ,
2017-02-02 15:08:21 -08:00
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : @"Print db stats." ) ;
#endregion
#region Diffdat
2017-02-02 15:08:21 -08:00
Feature diffdat = new Feature (
2018-01-23 15:55:04 -08:00
"Diffdat" ,
2017-02-02 15:08:21 -08:00
"diffdat" ,
2018-01-27 15:09:31 -08:00
"Creates a DAT file with those entries that are in -new DAT." ,
2017-02-02 15:08:21 -08:00
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : @ "Creates a DAT file with those entries that are in -new DAT file and not
in - old DAT file . Ignores those entries in - old that are not in - new . ");
diffdat . AddFeature ( outStringInput ) ;
diffdat . AddFeature ( oldStringInput ) ;
diffdat . AddFeature ( newStringInput ) ;
diffdat . AddFeature ( nameStringInput ) ;
diffdat . AddFeature ( descriptionStringInput ) ;
#endregion
#region Dir2Dat
2017-02-02 15:08:21 -08:00
Feature dir2dat = new Feature (
2018-01-23 15:55:04 -08:00
"Dir2Dat" ,
2017-02-02 15:08:21 -08:00
"dir2dat" ,
2018-01-27 15:09:31 -08:00
"Creates a DAT file for the specified input directory and saves it to the -out filename." ,
FeatureType . Flag ) ;
dir2dat . AddFeature ( outStringInput ) ;
dir2dat . AddFeature ( sourceStringInput ) ;
dir2dat . AddFeature ( nameStringInput ) ; // Defaults to "untitled"
dir2dat . AddFeature ( descriptionStringInput ) ;
#endregion
#region EDiffdat
Feature ediffdat = new Feature (
"EDiffdat" ,
"ediffdat" ,
"Creates a DAT file with those entries that are in -new DAT." ,
2017-02-02 15:08:21 -08:00
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : @ "Creates a DAT file with those entries that are in -new DAT files and not
in - old DAT files . Ignores those entries in - old that are not in - new . ");
ediffdat . AddFeature ( outStringInput ) ;
ediffdat . AddFeature ( oldStringInput ) ;
ediffdat . AddFeature ( newStringInput ) ;
2017-02-02 15:08:21 -08:00
2018-01-27 15:09:31 -08:00
#endregion
#region Export
// Unique to RombaSharp
2017-02-02 15:08:21 -08:00
Feature export = new Feature (
2018-01-23 15:55:04 -08:00
"Export" ,
2017-02-02 15:08:21 -08:00
"export" ,
"Exports db to export.csv" ,
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : "Exports db to standardized export.csv" ) ;
#endregion
#region Fixdat
2017-02-02 15:08:21 -08:00
Feature fixdat = new Feature (
2018-01-23 15:55:04 -08:00
"Fixdat" ,
2017-02-02 15:08:21 -08:00
"fixdat" ,
2018-01-27 15:09:31 -08:00
"For each specified DAT file it creates a fix DAT." ,
2017-02-02 15:08:21 -08:00
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : @ "For each specified DAT file it creates a fix DAT with the missing entries for
that DAT . If nothing is missing it doesn ' t create a fix DAT for that
particular DAT . ");
fixdat . AddFeature ( outStringInput ) ;
fixdat . AddFeature ( fixdatOnlyFlag ) ; // Enabled by default
fixdat . AddFeature ( workersInt32Input ) ;
fixdat . AddFeature ( subworkersInt32Input ) ;
#endregion
2017-02-02 15:08:21 -08:00
2018-01-27 15:09:31 -08:00
#region Import
// Unique to RombaSharp
2017-02-02 22:06:20 -08:00
Feature import = new Feature (
2018-01-23 15:55:04 -08:00
"Import" ,
2017-02-02 22:06:20 -08:00
"import" ,
"Import a database from a formatted CSV file" ,
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : @"Import a database from a formatted CSV file" ) ;
#endregion
#region Lookup
2017-02-02 22:06:20 -08:00
2017-02-02 15:08:21 -08:00
Feature lookup = new Feature (
2018-01-23 15:55:04 -08:00
"Lookup" ,
2017-02-02 15:08:21 -08:00
"lookup" ,
2018-01-27 15:09:31 -08:00
"For each specified hash it looks up any available information." ,
2017-02-02 15:08:21 -08:00
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : @"For each specified hash it looks up any available information (dat or rom)." ) ;
lookup . AddFeature ( sizeInt64Input ) ; // Defaults to -1
lookup . AddFeature ( outStringInput ) ;
#endregion
#region Memstats
2017-02-02 15:08:21 -08:00
Feature memstats = new Feature (
2018-01-23 15:55:04 -08:00
"Memstats" ,
2017-02-02 15:08:21 -08:00
"memstats" ,
2018-01-27 15:09:31 -08:00
"Prints memory stats." ,
2017-02-02 15:08:21 -08:00
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : @"Print memory stats." ) ;
#endregion
#region Merge
2017-02-02 15:08:21 -08:00
2017-02-02 21:57:34 -08:00
Feature merge = new Feature (
2018-01-23 15:55:04 -08:00
"Merge" ,
2017-02-02 21:57:34 -08:00
"merge" ,
2018-01-27 15:09:31 -08:00
"Merges depot" ,
FeatureType . Flag ,
longDescription : @"Merges specified depot into current depot." ) ;
merge . AddFeature ( onlyNeededFlag ) ;
merge . AddFeature ( resumeStringInput ) ;
merge . AddFeature ( workersInt32Input ) ;
merge . AddFeature ( skipInitialScanFlag ) ;
#endregion
#region Miss
// Unique to RombaSharp
2017-02-02 15:08:21 -08:00
Feature miss = new Feature (
2018-01-23 15:55:04 -08:00
"Miss" ,
2017-02-02 15:08:21 -08:00
"miss" ,
2018-01-27 15:09:31 -08:00
"Create miss and have file" ,
2017-02-02 15:08:21 -08:00
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : @"For each specified DAT file, create miss and have file" ) ;
#endregion
#region Progress
Feature progress = new Feature (
"Progress" ,
"progress" ,
"Shows progress of the currently running command." ,
FeatureType . Flag ,
longDescription : @"Shows progress of the currently running command." ) ;
#endregion
#region Purge Backup
2017-02-02 15:08:21 -08:00
Feature purgeBackup = new Feature (
2018-01-23 15:55:04 -08:00
"Purge Backup" ,
2017-02-02 15:08:21 -08:00
"purge-backup" ,
2018-01-27 15:09:31 -08:00
"Moves DAT index entries for orphaned DATs." ,
2017-02-02 15:08:21 -08:00
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : @ "Deletes DAT index entries for orphaned DATs and moves ROM files that are no
longer associated with any current DATs to the specified backup folder .
The files will be placed in the backup location using
a folder structure according to the original DAT master directory tree
structure . It also deletes the specified DATs from the DAT index . ");
purgeBackup . AddFeature ( backupStringInput ) ;
purgeBackup . AddFeature ( workersInt32Input ) ;
purgeBackup . AddFeature ( depotListStringInput ) ;
purgeBackup . AddFeature ( datsListStringInput ) ;
purgeBackup . AddFeature ( logOnlyFlag ) ;
#endregion
#region Purge Delete
2017-02-02 15:08:21 -08:00
2018-01-27 15:09:31 -08:00
// Unique to RombaSharp
2017-02-02 15:08:21 -08:00
Feature purgeDelete = new Feature (
2018-01-23 15:55:04 -08:00
"Purge Delete" ,
2017-02-02 15:08:21 -08:00
"purge-delete" ,
"Deletes DAT index entries for orphaned DATs" ,
2018-01-27 15:09:31 -08:00
FeatureType . Flag ) ;
purgeDelete . AddFeature ( logOnlyFlag ) ;
#endregion
#region Refresh DATs
2017-02-02 15:08:21 -08:00
Feature refreshDats = new Feature (
2018-01-23 15:55:04 -08:00
"Refresh DATs" ,
2017-02-02 15:08:21 -08:00
"refresh-dats" ,
2018-01-27 15:09:31 -08:00
"Refreshes the DAT index from the files in the DAT master directory tree." ,
2017-02-02 15:08:21 -08:00
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : @ "Refreshes the DAT index from the files in the DAT master directory tree.
Detects any changes in the DAT master directory tree and updates the DAT index
accordingly , marking deleted or overwritten dats as orphaned and updating
contents of any changed dats . ");
refreshDats . AddFeature ( workersInt32Input ) ;
refreshDats . AddFeature ( missingSha1sStringInput ) ;
2017-02-02 15:08:21 -08:00
2018-01-27 15:09:31 -08:00
#endregion
#region Recan Depots
// Unique to RombaSharp
Feature rescanDepots = new Feature (
"Rescan Depots" ,
"depot-rescan" ,
"Rescan a specific depot to get new information" ,
FeatureType . Flag ) ;
#endregion
#region Shutdown
2017-02-02 15:08:21 -08:00
Feature shutdown = new Feature (
2018-01-23 15:55:04 -08:00
"Shutdown" ,
2017-02-02 15:08:21 -08:00
"shutdown" ,
2018-01-27 15:09:31 -08:00
"Gracefully shuts down server." ,
FeatureType . Flag ,
longDescription : @"Gracefully shuts down server saving all the cached data." ) ;
#endregion
#region Version
Feature version = new Feature (
"Version" ,
"version" ,
"Prints version" ,
2017-02-02 15:08:21 -08:00
FeatureType . Flag ,
2018-01-27 15:09:31 -08:00
longDescription : @"Prints version." ) ;
#endregion
2017-02-02 15:08:21 -08:00
// Now, add all of the main features to the Help object
2018-01-23 15:55:04 -08:00
help . Add ( helpFeature ) ;
help . Add ( archive ) ;
help . Add ( build ) ;
2018-01-27 15:09:31 -08:00
help . Add ( cancel ) ;
help . Add ( datstats ) ;
help . Add ( dbstats ) ;
2018-01-23 15:55:04 -08:00
help . Add ( diffdat ) ;
help . Add ( dir2dat ) ;
2018-01-27 15:09:31 -08:00
help . Add ( ediffdat ) ;
2018-01-23 15:55:04 -08:00
help . Add ( export ) ;
help . Add ( fixdat ) ;
help . Add ( import ) ;
help . Add ( lookup ) ;
help . Add ( memstats ) ;
help . Add ( merge ) ;
help . Add ( miss ) ;
help . Add ( purgeBackup ) ;
help . Add ( purgeDelete ) ;
help . Add ( refreshDats ) ;
2018-01-27 15:09:31 -08:00
help . Add ( rescanDepots ) ;
2018-01-23 15:55:04 -08:00
help . Add ( progress ) ;
help . Add ( shutdown ) ;
2018-01-27 15:09:31 -08:00
help . Add ( version ) ;
2017-02-02 15:08:21 -08:00
return help ;
}
}
}