Command categories / parent commands

motaword allows you to access all aspects of MotaWord platform, from submitting files for translation to getting reports, from managing your glossary to style guides.

For all commands that motaword support, run:

> motaword help

Usage:
motaword [command]

Available Commands:
  async               Manage async operations
  auth                Authentication settings
  continuous-projects Manage your continuous projects
  debug               Debug your MotaWord configuration and environment
  documents           Manage documents
  get-access-token    Retrieve an access token to interact with the API.
  glossaries          Manage glossaries
  help                Help about any command
  help-config         Show CLI configuration help
  help-input          Show CLI input help
  projects            Manage projects
  reports             Manage reports
  search              Manage search operations
  static              Manage static endpoints
  stats               Manage stats
  strings             Manage strings
  styleguides         Manage styleguides
  translate           Instantly translate your content with your existing TM and MT resources. This is an alias to `continuous-projects translate`
  users               Manage users
  webhooks            Manage webhooks

Flags:
  -h, --help                   help for motaword
  -o, --output-format string   Output format [json, yaml] (default "json")
      --profile string         Credentials profile to use for authentication (default "default")
  -q, --query string           Filter / project results using JMESPath
      --raw                    Output result as raw rather than pretty JSON
      --server string          Override server URL
      --v                      Enable WARN level verbose log output
      --verbose                Enable DEBUG level verbose log output, same as --vvv flag
      --vv                     Enable INFO level verbose log output
      --vvv                    Enable DEBUG level verbose log output

Additional help topics:
  motaword blog                Manage blog articles
  motaword clients             Manage client account
  motaword token               Manage token operations

Use "motaword [command] --help" for more information about a command.

These are categories of commands. There are subcommands under each category.

Subcommands

Let's say we want to get some reports about my account:

> motaword reports
Usage:
  motaword reports [command]

Available Commands:
  get-language-pairs-report Returns a report of language pairs.
  get-projects-report       Returns a report of corporate account users.
  get-users-report          Returns a report of corporate account users.

We now see the available commands under reports category. Let's use get-language-pairs-report subcommand:

> motaword reports get-language-pairs-report

{
  "meta": {
    "paging": {
      "links": {
        "next": null,
        "previous": null,
        "self": {
          "href": "https://api.staging.motaword.com/v0/reports/language-pairs"
        }
      },
      "page": 1,
      "per_page": 2,
      "total_count": 2
    }
  },
  "report": [
    {
      "language_pair": {
        "source_language": "af",
        "target_language": "ak"
      },
      "spending": "343.42",
      "word_count": "2475"
    },
    {
      "language_pair": {
        "source_language": "en-US",
        "target_language": "fr"
      },
      "spending": "11.70",
      "word_count": "195"
    }
  ]
}

Most commands will return a JSON response. By using a tool like jq, you can process these JSON responses. Here is an example for getting a human-readable output from the above response:

> motaword reports get-language-pairs-report \
| jq '.report[] | "For \(.language_pair.source_language) into \(.language_pair.target_language), we spent $\(.spending)"'


"For af into ak, we spent $343.42"
"For en-US into fr, we spent $11.70"

Command parameters

Some commands accept parameters and JSON payloads. We can view what kind of parameters or JSON payload they can accept, we can use the --help flag:

> motaword projects get-project --help

Get single project

Usage:
  motaword projects get-project id [flags]

Flags:
  -h, --help            help for get-project
      --with[] string   Include detailed information. Possible values 'client', 'vendor', 'score'

get-project command only accepts and id parameter and with[] flag.

Some commands will accept JSON payloads, these are usually create/update commands (e.g. POST/PUT requests in HTTP).

We can view the shape of the request payload via --help. The request description is an OpenAPI specification. Here is an example (removed descriptions for brevity):

> motaword reports get-projects-report --help

## Request Schema (application/json)

properties:
  budget_code:
    type: string
  date_from:
    format: date-time
    type: string
  date_to:
    format: date-time
    type: string
  source_languages:
    items:
      type: string
    type: array
  target_languages:
    items:
      type: string
    type: array
  users:
    items:
      format: int64
      type: integer
    type: array
type: object

Usage:
  motaword reports get-projects-report [flags]

Flags:
  -h, --help   help for get-projects-report

According to the request schema in the help output, you can send this payload with this command (which will generate your projects report within these dates):

{
   "date_from":"2021-04-21T16:07:12.727Z",
   "date_to":"2021-05-21T16:07:12.727Z"
}

Sending JSON payload

JSON payloads like above can be sent by piping STDIN into the command.

If you have a simple payload, you can simply do this:

> echo '{"date_from":"2021-05-21T16:07:12.727Z","date_to":"2021-05-21T16:07:12.727Z"}' \
   | motaword reports get-projects-report

If you have a more complex payload, we recommend putting it in a file first, and then piping the file into the command:

> motaword reports get-projects-report < my-complex-payload.json