Skip to content

Configuration & profiles

Config file

GMC reads an optional JSON config from:

${GMC_CONFIG_DIR:-~/.config/gmc}/config.json

A profile selects a Merchant Center account (and, via stored OAuth, a credential). The file is a map of profiles plus an optional default:

json
{
  "defaultProfile": "prod",
  "profiles": {
    "prod": { "accountId": "123456789" },
    "staging": { "accountId": "987654321" }
  }
}

Inspect it with the gmc config commands:

sh
gmc config path      # where the config dir and file live
gmc config list      # configured profiles
gmc config current   # the profile resolved for this invocation

Resolution order

The effective profile is resolved from, in order: --profile, GMC_PROFILE, the file's defaultProfile, then "default".

The effective account id is resolved from: --account, GMC_ACCOUNT_ID, then the selected profile's accountId.

Global options

Every command accepts these:

FlagDescription
-j, --jsonEmit machine-readable JSON instead of human output
-p, --profile <name>Profile to use
-a, --account <id>Merchant Center account id (overrides the profile)
--no-colorDisable colored output
-V, --versionPrint the version
-h, --helpShow help

Environment variables

VariablePurpose
GMC_CONFIG_DIROverride the config/credential directory (default ~/.config/gmc)
GMC_PROFILESelect the profile
GMC_ACCOUNT_IDSet the account id
GMC_SERVICE_ACCOUNTService-account key (file path or raw JSON)
GOOGLE_APPLICATION_CREDENTIALSService-account key file (Google standard)

Exit codes

Commands set a classed exit code so CI can branch on the failure type:

CodeMeaning
0Success
1Generic error
2Usage (bad arguments/flags)
3Authentication failure
4Configuration failure
5Merchant API failure
6Preflight found gating compliance violations

In --json mode, failures print a { "ok": false, "error": { … } } envelope to stdout; success payloads print bare.

Released under the MIT License.