Skip to content

Commit

Permalink
feat(prompt): add autocomplete promt inteadof select
Browse files Browse the repository at this point in the history
  • Loading branch information
Alnyli07 committed Jan 23, 2024
1 parent 54b3adc commit 713df4e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Below is the list of commands currently supported by Appcircle CLI:

| Command | Description |
| --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| `appcircle` | AppCircle GUI |
| `appcircle (-i, --interactive)` | AppCircle GUI |
| `appcircle config <action> [options]` | View and edit Appcircle CLI properties |
| `appcircle login [--pat]` | Get an access token for the session |
| `appcircle listBuildProfiles` | Get the list of build profiles |
| `appcircle listDistributionProfiles` | Get the list of distribution profiles |
Expand Down Expand Up @@ -61,6 +62,16 @@ Example:
```
CURL_LOGGING= appcircle
```
## How to Configure your Appcircle CLI environment?
- Using the Appcircle CLI, add your custom configuration for self-hosted Appcircle

appcircle config add self_env
appcircle config set API_HOSTNAME https://api.your.appcircle.io
appcircle config set AUTH_HOSTNAME https://auth.your.appcircle.io

- You can change current configuration enviroment using `appcircle config current default`
- You can set all these settings via interactive mode `appcircle -i`
- Print help of config command `appcircle config -h`

## How to Connect your Appcircle Account within CLI?
- [Generate a personal access token from the Appcircle dashboard](https://docs.appcircle.io/appcircle-api/api-authentication)
Expand Down
12 changes: 7 additions & 5 deletions src/core/interactive-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import chalk from "chalk";
import ora from "ora";
import moment from "moment";
//@ts-ignore https://github.com/enquirer/enquirer/issues/212
import { prompt, Select, BooleanPrompt } from "enquirer";
import { prompt, Select, AutoComplete, BooleanPrompt } from "enquirer";
import { runCommand } from "./command-runner";
import { Commands, CommandParameterTypes } from "./commands";
import { APPCIRCLE_COLOR } from "../constant";
Expand Down Expand Up @@ -119,9 +119,10 @@ export const runCommandsInteractively = async () => {
)
);

const commandSelect = new Select({
const commandSelect = new AutoComplete({
name: "command",
message: "What do you want to do?",
message: `What do you want to do?${` (${Commands.length} Options)`}`,
limit: 10,
choices: [...Commands.map((command, index) => `${index + 1}. ${command.description}`)],
});

Expand Down Expand Up @@ -280,10 +281,11 @@ export const runCommandsInteractively = async () => {
//@ts-ignore
params[param.name] = await booleanPrompt.run();
} else if (param.type === CommandParameterTypes.SELECT) {
const selectPrompt = new Select({
const selectPrompt = new AutoComplete({
name: param.name,
message: param.description,
message: `${param.description}${param.params.length > 10 ?` (${param.params.length} Options)`: ''}`,
initial: param.defaultValue,
limit: 10,
choices: [
//@ts-ignore
...param.params.map((val: any) => val),
Expand Down
2 changes: 1 addition & 1 deletion src/core/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const writersMap: { [key in CommandTypes]: (data: any) => void } = {

[CommandTypes.CONFIG]: (data: any) => {

}
},
[CommandTypes.LOGIN]: (data: any) => {
console.log(chalk.italic(`export AC_ACCESS_TOKEN="${data.access_token}"\n`));
console.info(
Expand Down

0 comments on commit 713df4e

Please sign in to comment.