# CLI Configuration

## Setup CLI Initial Configuration <a href="#setup-cli-initial-configuration" id="setup-cli-initial-configuration"></a>

If you are using the CLI to try things out on-chain, you will need to configure the network and credentials you want the CLI to use.

This makes using the CLI easier and more secure as you will not be forced to repeatedly copy addresses or private keys.

:::caution If you still need to install the CLI, follow these steps. :::

1. Run `endless init` and follow the instructions in the command line.
   1. To use default settings, you can provide no input and just press "Enter". For example:
2. ```shell
   endless init

   Configuring for profile default
   Choose network from [devnet, testnet, mainnet, local, custom | defaults to devnet]

   No network given, using devnet...
   Enter your private key as a hex literal (0x...) [Current: None | No input: Generate new key (or keep one if present)]

   No key given, generating key...
   Account 0xa2146cf381c6eb4bc82c6c4b78ee02ab63ab8f6825456e143ceb5e929a4c7c2d doesn't exist, creating it and funding it with 100000000 Veins
   Account 0xa2146cf381c6eb4bc82c6c4b78ee02ab63ab8f6825456e143ceb5e929a4c7c2d funded successfully

   ---
   Endless CLI is now set up for account 0xa2146cf381c6eb4bc82c6c4b78ee02ab63ab8f6825456e143ceb5e929a4c7c2d as profile default!  Run `endless --help` for more information about commands
   Success
   ```
3. Later, if you want to update these settings, you can do so by running `endless init` again.
4. The rest of these configuration steps are optional / quality of life. To continue to use the CLI for your specific use case, follow the usage guide here.

### (Optional) Creating Named Configurations (Profiles) <a href="#optional-creating-named-configurations-profiles" id="optional-creating-named-configurations-profiles"></a>

For testing more complicated scenarios, you will often want multiple accounts on-chain. One way to do this is to create a named configuration which we call a profile.

To create a profile, run `endless init --profile <name_of_profile>`. The configuration you generate will be usable when calling CLI commands as replacements for arguments.

For example:

```shell
endless init --profile bob
...
...
Endless CLI is now set up for account 0x51024fd5e73c45de085b4c4f1d676273cd40578505364657df1ce14efbeba138 as profile bob!
```

### (Optional) Setting Up Shell Completion <a href="#optional-setting-up-shell-completion" id="optional-setting-up-shell-completion"></a>

One quality of life feature you can enable is shell auto-completions.

1. Determine which shell you are using (you can run `echo $SHELL` if you are unsure).
2. Look up where configuration files for shell completions go for that shell (it varies from shell to shell). The supported shells are `[bash, zsh, fish, PowerShell, elvish]`.
3. Run the following command with your specific shell and the output file for completions using your shell:

```shell
endless config generate-shell-completions --shell <YOUR_SHELL_HERE> --output-file <OUTPUT_DESTINATION_FOR_YOUR_SHELL>
```

Example command for [`oh my zsh`](https://ohmyz.sh/):

```shell
endless config generate-shell-completions --shell zsh --output-file ~/.oh-my-zsh/completions/_endless
```

### (Optional) Global Config <a href="#optional-global-config" id="optional-global-config"></a>

By default, the CLI will look for a configuration in `.endless/config.yaml` in each workspace directory. If you would like to use a shared configuration for all workspaces, you can follow these steps:

1. Create a folder in your home directory called `.endless` (so it has the path `~/.endless`).
2. Create a yaml file inside `.endless` called `global_config.yaml`.
3. Run the command:

```
endless config set-global-config --config-type global
```

You should see:

```
config_type:Global
default_prompt_response:Prompt
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.endless.link/endless/devbuild/build/endless-cli/cli-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
