CLI: Code Generation
The nouto codegen command generates a code snippet from a request in a collection file.
nouto codegen <collection-file> --request <name-or-id> --target <lang> [options]Options
Section titled “Options”| Option | Description | Default |
|---|---|---|
--request <name-or-id> |
Request name or ID (required) | |
-t, --target <lang> |
Target language (required) | |
-o, --output <file> |
Output file (stdout if omitted) | stdout |
--list-targets |
List all available targets |
List Available Targets
Section titled “List Available Targets”node packages/cli/dist/bin/cli.js codegen --list-targetsOutput:
Available code generation targets:
curl Shell - cURL javascript-fetch JavaScript - Fetch javascript-axios JavaScript - Axios python-requests Python - Requests csharp C# - HttpClient go Go - net/http java Java - HttpClient php PHP - cURL swift Swift - URLSession dart Dart - http powershell PowerShell typescript-types TypeScript TypesExamples
Section titled “Examples”Generate cURL
Section titled “Generate cURL”node packages/cli/dist/bin/cli.js codegen api.nouto.json --request "Create User" --target curlGenerate Python and save to file
Section titled “Generate Python and save to file”node packages/cli/dist/bin/cli.js codegen api.nouto.json \ --request "Create User" \ --target python-requests \ --output create_user.pyGenerate Go code
Section titled “Generate Go code”node packages/cli/dist/bin/cli.js codegen api.nouto.json --request "List Users" --target goWhat Gets Included
Section titled “What Gets Included”The generated code includes:
- HTTP method and full URL (with query parameters)
- All enabled headers
- Request body (JSON, form data, URL-encoded, text)
- Authentication supported by the selected target, including Basic, Bearer, API Key, OAuth 2.0, AWS Signature v4, Digest, and NTLM
- TypeScript interface output when the selected target is
typescript-types
Variable placeholders ({{variable}}) are left as-is in the generated code since the CLI does not resolve them during code generation.
Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
0 |
Success |
2 |
Collection file not found |
4 |
Invalid collection format |
5 |
Request not found |
7 |
Other error (missing arguments, invalid target) |
