SciresM / hactool

hactool is a tool to view information about, decrypt, and extract common file formats for the Nintendo Switch, especially Nintendo Content Archives.
ISC License
982 stars 151 forks source link

List of input file types shown to user is incomplete #92

Open x0rloser opened 4 years ago

x0rloser commented 4 years ago

The usage info for the tool does not show all supported input file types. So unless the user looks at the sourcecode they might not realise there are other types that are supported. I came across this issue trying to access a save file, but there was no "save" filetype listed in usage so couldnt work out what i was doing wrong until i looked at the sourcecode.

So need to make this usage:

  -t, --intype=type  Specify input file type [nca, xci, pfs0, romfs, hfs0, npdm, pk11, pk21, ini1, kip1, nax0, keygen]

match these available options

            case 't':
                if (!strcmp(optarg, "nca")) {
                    nca_ctx.tool_ctx->file_type = FILETYPE_NCA;
                } else if (!strcmp(optarg, "pfs0") || !strcmp(optarg, "exefs")) {
                    nca_ctx.tool_ctx->file_type = FILETYPE_PFS0;
                } else if (!strcmp(optarg, "romfs")) {
                    nca_ctx.tool_ctx->file_type = FILETYPE_ROMFS;
                } else if (!strcmp(optarg, "nca0_romfs") || !strcmp(optarg, "nca0romfs") || !strcmp(optarg, "betaromfs") || !strcmp(optarg, "beta_romfs")) {
                    nca_ctx.tool_ctx->file_type = FILETYPE_NCA0_ROMFS;
                } else if (!strcmp(optarg, "hfs0")) {
                    nca_ctx.tool_ctx->file_type = FILETYPE_HFS0;
                } else if (!strcmp(optarg, "xci") || !strcmp(optarg, "gamecard") || !strcmp(optarg, "gc")) {
                    nca_ctx.tool_ctx->file_type = FILETYPE_XCI;
                } else if (!strcmp(optarg, "npdm") || !strcmp(optarg, "meta")) {
                    nca_ctx.tool_ctx->file_type = FILETYPE_NPDM;
                } else if (!strcmp(optarg, "package1") || !strcmp(optarg, "pk11")) {
                    nca_ctx.tool_ctx->file_type = FILETYPE_PACKAGE1;
                } else if (!strcmp(optarg, "package2") || !strcmp(optarg, "pk21")) {
                    nca_ctx.tool_ctx->file_type = FILETYPE_PACKAGE2;
                } else if (!strcmp(optarg, "ini1")) {
                    nca_ctx.tool_ctx->file_type = FILETYPE_INI1;
                } else if (!strcmp(optarg, "kip1") || !strcmp(optarg, "kip")) {
                    nca_ctx.tool_ctx->file_type = FILETYPE_KIP1;
                } else if (!strcmp(optarg, "nso0") || !strcmp(optarg, "nso")) {
                    nca_ctx.tool_ctx->file_type = FILETYPE_NSO0;
                } else if (!strcmp(optarg, "nax0") || !strcmp(optarg, "nax")) {
                    nca_ctx.tool_ctx->file_type = FILETYPE_NAX0;
                } else if (!strcmp(optarg, "keygen") || !strcmp(optarg, "keys") || !strcmp(optarg, "boot0") || !strcmp(optarg, "boot")) {
                    nca_ctx.tool_ctx->file_type = FILETYPE_BOOT0;
                } else if (!strcmp(optarg, "save")) {
                    nca_ctx.tool_ctx->file_type = FILETYPE_SAVE;
                }
                break;

Since there are quite a few options for the intype parameter it might help to list them in usage in alphabetical order? Also group together the different intypes that are equivalent since users may not be aware they are the same thing.

The resulting usage is a lot longer, but since filetype is required to correctly perform any action it seems worthwhile.

So perhaps something like:

"  -t, --intype=type  Specify input file type\n"
"                     [hfs0, ini1, keygen/keys/boot0/boot, kip/kip1, nax/nax0,\n"
"                      nca, nca0romfs/nca0_romfs/betaromfs/beta_romfs, npdm/meta,\n"
"                      nso/nso0, package1/pk11, package2/pk21, pfs0/exefs, romfs,\n"
"                      save, xci/gamecard/gc]\n"
shchmue commented 4 years ago

this was addressed some time ago, just needs merge. it’s included in this PR https://github.com/SciresM/hactool/pull/88

x0rloser commented 4 years ago

PR #88 only adds the "save" type. Still missing after that are:

Also still missing is the inclusion of the equivalent types, such as: pfs0/exefs instead of just pfs0. This would help n00bs like me who might not be aware that pfs0 and exefs are the same thing. This goes for all equivalencies, not just the pfs0 one I used as an example.