Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"dependencies": {
"@inquirer/confirm": "^3.1.22",
"@inquirer/password": "^2.2.0",
"@oclif/core": "^4.5.2",
"@oclif/core": "autocomplete",
"@oclif/table": "^0.4.12",
"@salesforce/core": "^8.18.7",
"@salesforce/kit": "^3.2.3",
Expand Down
40 changes: 39 additions & 1 deletion src/flags/orgFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
import { Flags } from '@oclif/core';
import { ConfigAggregator, Messages, Org, OrgConfigProperties } from '@salesforce/core';
import { ConfigAggregator, Messages, Org, OrgConfigProperties, StateAggregator } from '@salesforce/core';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/sf-plugins-core', 'messages');
Expand Down Expand Up @@ -110,6 +110,14 @@ export const getHubOrThrow = async (aliasOrUsername?: string): Promise<Org> => {
export const optionalOrgFlag = Flags.custom({
char: 'o',
noCacheDefault: true,
completion: {
options: async () => {
const stateAggregator = await StateAggregator.getInstance();
const orgs = (await stateAggregator.orgs.list()).map((o) => o.replace('.json', ''));
const aliases = Object.keys(stateAggregator.aliases.getAll());
return [...orgs, ...aliases];
},
},
parse: async (input: string | undefined) => maybeGetOrg(input),
summary: messages.getMessage('flags.optionalTargetOrg.summary'),
default: async () => maybeGetOrg(),
Expand Down Expand Up @@ -148,6 +156,14 @@ export const requiredOrgFlag = Flags.custom({
char: 'o',
summary: messages.getMessage('flags.targetOrg.summary'),
noCacheDefault: true,
completion: {
options: async () => {
const stateAggregator = await StateAggregator.getInstance();
const orgs = (await stateAggregator.orgs.list()).map((o) => o.replace('.json', ''));
const aliases = Object.keys(stateAggregator.aliases.getAll());
return [...orgs, ...aliases];
},
},
parse: async (input: string | undefined) => getOrgOrThrow(input),
default: async () => getOrgOrThrow(),
defaultHelp: async (context) => {
Expand Down Expand Up @@ -188,6 +204,17 @@ export const requiredHubFlag = Flags.custom({
noCacheDefault: true,
parse: async (input: string | undefined) => getHubOrThrow(input),
default: async () => getHubOrThrow(),
completion: {
options: async () => {
const sa = await StateAggregator.getInstance();
const devHubs = (await sa.orgs.readAll()).filter((o) => o.isDevHub).map((o) => o.username ?? '');
const devHubAliases = Object.entries(sa.aliases.getAll())
.filter(([, username]) => devHubs.includes(username ?? ''))
.map(([alias]) => alias);

return [...devHubs, ...devHubAliases];
},
},
defaultHelp: async (context) => {
if (context.options instanceof Org) {
const org = context.options as Org;
Expand Down Expand Up @@ -225,6 +252,17 @@ export const optionalHubFlag = Flags.custom({
noCacheDefault: true,
parse: async (input: string | undefined) => maybeGetHub(input),
default: async () => maybeGetHub(),
completion: {
options: async () => {
const sa = await StateAggregator.getInstance();
const devHubs = (await sa.orgs.readAll()).filter((o) => o.isDevHub).map((o) => o.username ?? '');
const devHubAliases = Object.entries(sa.aliases.getAll())
.filter(([, username]) => devHubs.includes(username ?? ''))
.map(([alias]) => alias);

return [...devHubs, ...devHubAliases];
},
},
defaultHelp: async (context) => {
if (context.options instanceof Org) {
const org = context.options as Org;
Expand Down
24 changes: 18 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -556,23 +556,23 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@oclif/core@^4.5.2":
version "4.5.2"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-4.5.2.tgz#4db8a365fa7e9e33af272294f710a7f3f25538e2"
integrity sha512-eQcKyrEcDYeZJKu4vUWiu0ii/1Gfev6GF4FsLSgNez5/+aQyAUCjg3ZWlurf491WiYZTXCWyKAxyPWk8DKv2MA==
"@oclif/core@autocomplete":
version "4.5.6-autocomplete.0"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-4.5.6-autocomplete.0.tgz#749f8a5fbdfc62f57e32aef37b6affefb045cdb0"
integrity sha512-PTYvKFHMR/rECFvzAvZqfrq31I8BpIM15qz9+X4BMf3lx9gbYJqPpRi4bOR8ullb6ddUVjDGRENRZQlBznsEgw==
dependencies:
ansi-escapes "^4.3.2"
ansis "^3.17.0"
clean-stack "^3.0.1"
cli-spinners "^2.9.2"
debug "^4.4.0"
debug "^4.4.3"
ejs "^3.1.10"
get-package-type "^0.1.0"
indent-string "^4.0.0"
is-wsl "^2.2.0"
lilconfig "^3.1.3"
minimatch "^9.0.5"
semver "^7.6.3"
semver "^7.7.3"
string-width "^4.2.3"
supports-color "^8"
tinyglobby "^0.2.14"
Expand Down Expand Up @@ -1816,6 +1816,13 @@ debug@^3.2.7:
dependencies:
ms "^2.1.1"

debug@^4.4.3:
version "4.4.3"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.3.tgz#c6ae432d9bd9662582fce08709b038c58e9e3d6a"
integrity sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==
dependencies:
ms "^2.1.3"

decamelize-keys@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.1.tgz#04a2d523b2f18d80d0158a43b895d56dff8d19d8"
Expand Down Expand Up @@ -4784,6 +4791,11 @@ semver@^7.3.4, semver@^7.5.3, semver@^7.5.4, semver@^7.6.0, semver@^7.6.3:
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143"
integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==

semver@^7.7.3:
version "7.7.3"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.3.tgz#4b5f4143d007633a8dc671cd0a6ef9147b8bb946"
integrity sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==

sentence-case@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/sentence-case/-/sentence-case-3.0.4.tgz#3645a7b8c117c787fde8702056225bb62a45131f"
Expand Down
Loading