Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add a command line tool #36

Open
LittleFall opened this issue Mar 10, 2023 · 3 comments
Open

Feature Request: Add a command line tool #36

LittleFall opened this issue Mar 10, 2023 · 3 comments

Comments

@LittleFall
Copy link

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?

@Fusion86
Copy link
Owner

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

@LittleFall
Copy link
Author

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.

@Fusion86
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants