NX-Editor / NxEditor

A general editor for editing first-party Nintendo formats. Primary aimed at support for Tears of the Kingdom files and more modern Nintendo Switch files.
GNU Affero General Public License v3.0
78 stars 5 forks source link

Command-Line Interface #30

Open ArchLeaders opened 1 year ago

ArchLeaders commented 1 year ago

General discussion and proposals for the CLI (command line interface) implementation.

ArchLeaders commented 1 year ago

Usage proposal

nx-editor.exe <action> <input_file> [-f|--flags] FLAGS

Action

Actions can be defined in the ReactiveEditor impl via a common interface (ICommandModel) and/or in a global action process for file-type agonistic actions (e.g. De/CompressZs).

e.g.

public class SarcViewModel : ReactiveEditor, ICommandModel
{
    // . . .

    public Task ICommandModel.ProcessAction(string actionName, Dictionary<char, string> flags)
    {
         // Could also be automatically
         // processed with reflection
         return actionName switch {
             "Extract" => ExtractFile(flags['k']),
             _ => throw new Exception($"Action {actionName} was not found")
         };
    }

    // . . .
}

Input File

The source (input) file used to identify the ReactiveEditor and consequently operate actions on.

Flags

An infinite array of [-x|--xx] XXX type flag arrangements specific to each ReactiveEditor/Action.

e.g. for SarcViewModel

[-k|--key] KEY
--key "Some/Sarc/Path"

Documentation

Given the modularity and verbosity of the rest of this system, it would follow that the docs could also be auto-generated from the current state of editors/actions.

This might prove difficult with the current proposal, so further discussion should follow once we have a clearer implementation spec.

ArchLeaders commented 1 year ago

Other Notes

A CLI-safe abstraction of the ReactiveEditor may be a good idea to avoid complications with UI code while still maintaining the same organization of parsers.

This might be possible by just casting to an interface level (ICommandModel) and moving some implementations around (mainly the ctor) to give the required access to the interface.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.