Skip to content

Commit

Permalink
Enhance credential prompt to use server address from config
Browse files Browse the repository at this point in the history
  • Loading branch information
royroyee committed Jan 29, 2024
1 parent c2f4cb6 commit 8af4721
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ $ alpacon login

$ alpacon login -s [SERVER URL] -u [USERNAME] -p [PASSWORD]
```
Successful login creates `config.json` in `~/.alpacon`, containing server address, API token, and token expiration (~1 week).
This file is essential for command execution and a new login is required upon token expiration.
A successful login generates a `config.json` file in `~/.alpacon`, which includes the server address, API token, and token expiration time (approximately 1 week).
This file is crucial for executing commands, and you will need to log in again once the token expires.

Upon re-login, the Alpacon CLI will automatically reuse the server address from `config.json`, unless you provide all the flags (-s, -u, -p).
If you need to connect to a different server or change the server address, you can either directly modify the `config.json` file in ~/.alpacon or provide all flags to specify a new server URL.

#### Default Server URL
If you do not explicitly specify the server URL (-s) in the command, the default value `https://alpacon.io` is used.
Expand Down
2 changes: 1 addition & 1 deletion cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func promptForCredentials() {
configFile, err := config.LoadConfig()
if err == nil && configFile.ServerAddress != "" {
loginRequest.ServerAddress = configFile.ServerAddress
fmt.Println("Using server address from config:", configFile.ServerAddress, ". To modify it, edit `~/.alpacon/config.json`")
fmt.Println("Using server address from config:", configFile.ServerAddress, ". Modify it in `~/.alpacon/config.json` or use all flags (-s, -u, -p) for changes.")
} else {
loginRequest.ServerAddress = utils.PromptForInput("Server Address[https://alpacon.io]: ")
if loginRequest.ServerAddress == "" {
Expand Down

0 comments on commit 8af4721

Please sign in to comment.