Cirilla icon indicating copy to clipboard operation
Cirilla copied to clipboard

Feature Request: Add a command line tool

Open LittleFall opened this issue 2 years ago • 3 comments

Firstly very much thanks for this project!!

I want to convert many .gmd files to .csv/.txt in batch, is there some way to do this?

LittleFall avatar Mar 10 '23 17:03 LittleFall

Do you also want to convert them back? E.g. csv -> gmd?

Fusion86 avatar Mar 10 '23 20:03 Fusion86

I only have a one-sided need right now, I want to count some lines of The Great Ace Attorney.

I think being able to turn back would be a great feature too, depending on you.

LittleFall avatar Mar 11 '23 03:03 LittleFall

The GMDTool does something like this. You could even edit the Program.cs to count the newlines.

E.g. something like this. I didn't really test this code. image

Or you could edit it to spit out CSV stuff.

CsvConfiguration csvConfig = new CsvConfiguration(CultureInfo.InvariantCulture)
{
    Delimiter = ";",
    ShouldQuote = _ => true, // Always insert quotes
    HasHeaderRecord = false,
    AllowComments = true, // Uses # to identify comments
};
using CsvWriter writer = new CsvWriter(Console.Out, csvConfig);

var records = gmd.Entries
    .OfType<GMD_Entry>()
    .Select(x => new StringKeyValuePair(x.Key, x.Value))
    .ToList();

writer.WriteRecords(records);

I attached three archives with the compiled GMDTool. These require .NET 5. The second archive prints the contents as CSV, and the third only prints the total line count in the GMD (split by \n).

GMDTool.zip GMDTool-CSV.zip GMDTool-PrintLineCount.zip

Though keep in mind that this is all experimental, so it could just crash or something.

Fusion86 avatar Mar 14 '23 22:03 Fusion86