Skip to content

Commit

Permalink
fix: update run:function flags to match PRD (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
cafreeman authored Jun 16, 2021
1 parent 37bf05e commit 5fc61b5
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 76 deletions.
94 changes: 46 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Functions plugin for the SF CLI

<!-- toc -->

- [plugin-functions](#plugin-functions)
- [Usage](#usage)
- [Commands](#commands)
<!-- tocstop -->
Expand All @@ -27,27 +28,24 @@ Now you should be able to run functions commands, e.g. `sfdx env:list`, `sfdx lo

<!-- commands -->

- [plugin-functions](#plugin-functions)
- [Usage](#usage)
- [Commands](#commands)
- [`sf env:create:compute`](#sf-envcreatecompute)
- [`sf env:delete`](#sf-envdelete)
- [`sf env:display`](#sf-envdisplay)
- [`sf env:list`](#sf-envlist)
- [`sf env:log:tail`](#sf-envlogtail)
- [`sf env:logdrain:add`](#sf-envlogdrainadd)
- [`sf env:logdrain:list`](#sf-envlogdrainlist)
- [`sf env:logdrain:remove`](#sf-envlogdrainremove)
- [`sf env:var:get KEY`](#sf-envvarget-key)
- [`sf env:var:list`](#sf-envvarlist)
- [`sf env:var:set`](#sf-envvarset)
- [`sf env:var:unset`](#sf-envvarunset)
- [`sf generate:function`](#sf-generatefunction)
- [`sf generate:project`](#sf-generateproject)
- [`sf login:functions`](#sf-loginfunctions)
- [`sf project:deploy:functions`](#sf-projectdeployfunctions)
- [`sf run:function`](#sf-runfunction)
- [`sf run:function:start`](#sf-runfunctionstart)
- [`sf env:create:compute`](#sf-envcreatecompute)
- [`sf env:delete`](#sf-envdelete)
- [`sf env:display`](#sf-envdisplay)
- [`sf env:list`](#sf-envlist)
- [`sf env:log:tail`](#sf-envlogtail)
- [`sf env:logdrain:add`](#sf-envlogdrainadd)
- [`sf env:logdrain:list`](#sf-envlogdrainlist)
- [`sf env:logdrain:remove`](#sf-envlogdrainremove)
- [`sf env:var:get KEY`](#sf-envvarget-key)
- [`sf env:var:list`](#sf-envvarlist)
- [`sf env:var:set`](#sf-envvarset)
- [`sf env:var:unset`](#sf-envvarunset)
- [`sf generate:function`](#sf-generatefunction)
- [`sf generate:project`](#sf-generateproject)
- [`sf login:functions`](#sf-loginfunctions)
- [`sf project:deploy:functions`](#sf-projectdeployfunctions)
- [`sf run:function`](#sf-runfunction)
- [`sf run:function:start`](#sf-runfunctionstart)

## `sf env:create:compute`

Expand All @@ -67,7 +65,7 @@ EXAMPLES
$ sfdx env:create:compute --connected-org my-scratch-org
```

_See code: [src/commands/env/create/compute.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/env/create/compute.ts)_
_See code: [src/commands/env/create/compute.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/env/create/compute.ts)_

## `sf env:delete`

Expand All @@ -86,7 +84,7 @@ EXAMPLES
$ sfdx env:delete --environment=billingApp-Scratch1 --confirm=billingApp-Scratch1
```

_See code: [src/commands/env/delete.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/env/delete.ts)_
_See code: [src/commands/env/delete.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/env/delete.ts)_

## `sf env:display`

Expand All @@ -104,7 +102,7 @@ EXAMPLE
$ sfdx env:display --environment=billingApp-Scratch1
```

_See code: [src/commands/env/display.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/env/display.ts)_
_See code: [src/commands/env/display.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/env/display.ts)_

## `sf env:list`

Expand All @@ -127,7 +125,7 @@ EXAMPLES
$ sfdx env:list --environment-type org --environment-type compute
```

_See code: [src/commands/env/list.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/env/list.ts)_
_See code: [src/commands/env/list.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/env/list.ts)_

## `sf env:log:tail`

Expand All @@ -144,7 +142,7 @@ EXAMPLE
sfdx env:log:tail --environment=billingApp-Scratch1
```

_See code: [src/commands/env/log/tail.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/env/log/tail.ts)_
_See code: [src/commands/env/log/tail.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/env/log/tail.ts)_

## `sf env:logdrain:add`

Expand All @@ -162,7 +160,7 @@ EXAMPLE
$ sfdx env:logdrain:add --environment=billingApp-Sandbox --url=https://example.com/drain
```

_See code: [src/commands/env/logdrain/add.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/env/logdrain/add.ts)_
_See code: [src/commands/env/logdrain/add.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/env/logdrain/add.ts)_

## `sf env:logdrain:list`

Expand All @@ -180,7 +178,7 @@ EXAMPLE
$ sfdx env:logdrain:list --environment=billingApp-Sandbox
```

_See code: [src/commands/env/logdrain/list.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/env/logdrain/list.ts)_
_See code: [src/commands/env/logdrain/list.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/env/logdrain/list.ts)_

## `sf env:logdrain:remove`

Expand All @@ -198,7 +196,7 @@ EXAMPLE
$ sfdx env:logdrain:remove --environment=billingApp-Sandbox --url=syslog://syslog-a.logdna.com:11137
```

_See code: [src/commands/env/logdrain/remove.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/env/logdrain/remove.ts)_
_See code: [src/commands/env/logdrain/remove.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/env/logdrain/remove.ts)_

## `sf env:var:get KEY`

Expand All @@ -215,7 +213,7 @@ EXAMPLE
$ sfdx env:var:get foo --environment=my-environment
```

_See code: [src/commands/env/var/get.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/env/var/get.ts)_
_See code: [src/commands/env/var/get.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/env/var/get.ts)_

## `sf env:var:list`

Expand All @@ -232,7 +230,7 @@ EXAMPLE
$ sfdx env:var:list --environment=my-environment
```

_See code: [src/commands/env/var/list.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/env/var/list.ts)_
_See code: [src/commands/env/var/list.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/env/var/list.ts)_

## `sf env:var:set`

Expand All @@ -249,7 +247,7 @@ EXAMPLE
$ sfdx env:var:set foo=bar --environment=my-environment
```

_See code: [src/commands/env/var/set.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/env/var/set.ts)_
_See code: [src/commands/env/var/set.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/env/var/set.ts)_

## `sf env:var:unset`

Expand All @@ -266,7 +264,7 @@ EXAMPLE
$ sfdx env:var:unset foo --environment=my-environment
```

_See code: [src/commands/env/var/unset.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/env/var/unset.ts)_
_See code: [src/commands/env/var/unset.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/env/var/unset.ts)_

## `sf generate:function`

Expand All @@ -287,7 +285,7 @@ EXAMPLE
$ sfdx evergreen:function:create MyFunction --language=javascript
```

_See code: [src/commands/generate/function.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/generate/function.ts)_
_See code: [src/commands/generate/function.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/generate/function.ts)_

## `sf generate:project`

Expand All @@ -299,7 +297,7 @@ OPTIONS
-n, --name=name (required) name of the generated project
```

_See code: [src/commands/generate/project.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/generate/project.ts)_
_See code: [src/commands/generate/project.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/generate/project.ts)_

## `sf login:functions`

Expand All @@ -313,7 +311,7 @@ EXAMPLE
$ sfdx login:functions
```

_See code: [src/commands/login/functions.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/login/functions.ts)_
_See code: [src/commands/login/functions.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/login/functions.ts)_

## `sf project:deploy:functions`

Expand All @@ -332,7 +330,7 @@ OPTIONS
--force ignore warnings and overwrite remote repository (not allowed in production)
```

_See code: [src/commands/project/deploy/functions.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/project/deploy/functions.ts)_
_See code: [src/commands/project/deploy/functions.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/project/deploy/functions.ts)_

## `sf run:function`

Expand All @@ -343,21 +341,21 @@ USAGE
$ sf run:function
OPTIONS
-H, --headers=headers set headers
-p, --payload=payload set the payload of the cloudevent. also accepts @file.txt format
-t, --targetusername=targetusername username or alias for the target org; overrides default target org
-u, --url=url (required) url of the function to run
--structured set the cloudevent to be emitted as a structured cloudevent (json)
-H, --headers=headers set headers
-l, --url=url (required) url of the function to run
-o, --connected-org=connected-org username or alias for the target org; overrides default target org
-p, --payload=payload set the payload of the cloudevent. also accepts @file.txt format
-s, --structured set the cloudevent to be emitted as a structured cloudevent (json)
EXAMPLE
$ sfdx run:function -u http://localhost:8080 -p '{"id": 12345}'
$ sfdx run:function -u http://localhost:8080 -p '@file.json'
$ echo '{"id": 12345}' | sfdx run:function -u http://localhost:8080
$ sfdx run:function -u http://localhost:8080 -p '{"id": 12345}' --structured
$ sfdx run:function -l http://localhost:8080 -p '{"id": 12345}'
$ sfdx run:function -l http://localhost:8080 -p '@file.json'
$ echo '{"id": 12345}' | sfdx run:function -l http://localhost:8080
$ sfdx run:function -l http://localhost:8080 -p '{"id": 12345}' --structured
```

_See code: [src/commands/run/function.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/run/function.ts)_
_See code: [src/commands/run/function.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/run/function.ts)_

## `sf run:function:start`

Expand Down Expand Up @@ -386,6 +384,6 @@ EXAMPLE
$ sfdx run:function:start --network host --no-pull --clear-cache --debug-port 9000 --port 5000
```

_See code: [src/commands/run/function/start.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.2/src/commands/run/function/start.ts)_
_See code: [src/commands/run/function/start.ts](https://github.com/salesforcecli/plugin-functions/blob/v0.2.3/src/commands/run/function/start.ts)_

<!-- commandsstop -->
2 changes: 1 addition & 1 deletion command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
{
"command": "run:function",
"plugin": "@salesforce/plugin-functions",
"flags": ["headers", "payload", "structured", "targetusername", "url"]
"flags": ["connected-org", "headers", "payload", "structured", "url"]
},
{
"command": "run:function:start",
Expand Down
19 changes: 10 additions & 9 deletions src/commands/run/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ export default class Invoke extends Command {

static examples = [
`
$ sfdx run:function -u http://localhost:8080 -p '{"id": 12345}'
$ sfdx run:function -u http://localhost:8080 -p '@file.json'
$ echo '{"id": 12345}' | sfdx run:function -u http://localhost:8080
$ sfdx run:function -u http://localhost:8080 -p '{"id": 12345}' --structured
$ sfdx run:function -l http://localhost:8080 -p '{"id": 12345}'
$ sfdx run:function -l http://localhost:8080 -p '@file.json'
$ echo '{"id": 12345}' | sfdx run:function -l http://localhost:8080
$ sfdx run:function -l http://localhost:8080 -p '{"id": 12345}' --structured
`,
];

static flags = {
url: flags.string({
char: 'u',
char: 'l',
description: 'url of the function to run',
required: true,
}),
Expand All @@ -45,10 +45,11 @@ export default class Invoke extends Command {
description: 'set the payload of the cloudevent. also accepts @file.txt format',
}),
structured: flags.boolean({
char: 's',
description: 'set the cloudevent to be emitted as a structured cloudevent (json)',
}),
targetusername: flags.string({
char: 't',
'connected-org': flags.string({
char: 'o',
description: 'username or alias for the target org; overrides default target org',
}),
};
Expand All @@ -68,7 +69,7 @@ export default class Invoke extends Command {

try {
cli.action.start(`${herokuColor.cyanBright('POST')} ${flags.url}`);
const cloudevent = await this.buildCloudevent(data, flags.targetusername, flags.structured);
const cloudevent = await this.buildCloudevent(data, flags['connected-org'], flags.structured);
const response = await this.sendRequest(cloudevent, flags.url, flags.headers, flags.structured);
cli.action.stop(herokuColor.greenBright(response.status.toString()));
this.writeResponse(response);
Expand Down Expand Up @@ -130,7 +131,7 @@ export default class Invoke extends Command {
return { sfcontext, sffncontext };
} catch (error) {
if (error.name === 'AuthInfoCreationError' || error.name === 'NoUsername') {
this.warn('No -t targetusername or defaultusername found, context will be partially initialized');
this.warn('No -o connected org or defaultusername found, context will be partially initialized');
const fakeUserContext = {
orgId: '000000000000000000',
orgDomainUrl: '',
Expand Down
Loading

0 comments on commit 5fc61b5

Please sign in to comment.