Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add basic skeleton cli #2

Merged
merged 10 commits into from
Oct 15, 2024
Merged

Conversation

PhearZero
Copy link
Member

@PhearZero PhearZero commented Oct 1, 2024

ℹ Overview

  • adds cobra, viper, and bubbletea
  • uses ENV prefix ALGORUN
  • uses configuration fallback: cwd() -> $HOME -> /etc/algorun
  • checks for ALGORAND_DATA and uses algod.admin.token and EntrypointAddress
  • configures channel for StatusAfterBlock and updates the View
  • generates API client from OAS specification, similar to go-algorand/go-algorand-sdk

📝 Related Issues

✅ Acceptance:

  • Basic tui project structure for v1 milestone
  • Config for algod connection
    • ENV Variables
    • CLI Flags
    • File
  • Basic unit testing
  • Print latest round on a loop (wait StatusAfterBlock)

@PhearZero PhearZero added this to the Milestone 1 milestone Oct 1, 2024
@PhearZero PhearZero self-assigned this Oct 1, 2024
switch msg.String() {

// These keys should exit the program.
case "ctrl+c", "q":
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realise bubbletea highjacks SIGINT and you have to explicitly define the behaviour. Whilst testing it I also thought I should include a contribution. 😄

Suggested change
case "ctrl+c", "q":
case "ctrl+c", "q", "esc":

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I'm thinking about it, maybe esc shouldn't exit the program, and it should just return you back to the main window (assuming modals or other views will eventually exist). Depends how the larger design looks I guess. Great work so far though!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been a great experience! I really like what the baseline offers and where your thinking is heading. What the framework unlocks is pretty impressive!!

I almost added the editor integration for the config files and had to stop myself several times from diving down the rabbit hole 😂

@tasosbit
Copy link
Contributor

tasosbit commented Oct 1, 2024

Should we add support for ALGORAND_DATA env var, and then parse config.json / algod.admin.token to use as config defaults?

Explicit configuration should ignore those, but it would be good UX if it can work with zero extra configuration out of the box

@PhearZero
Copy link
Member Author

Should we add support for ALGORAND_DATA env var, and then parse config.json / algod.admin.token to use as config defaults?

Love this idea! We could build a sandbox docker image and use it for testing

@PhearZero PhearZero force-pushed the chore/skeleton-bubbletea-project branch from f552a63 to af51533 Compare October 7, 2024 21:15
@PhearZero PhearZero marked this pull request as ready for review October 7, 2024 21:16

// Watch uses algod.StatusAfterBlock to wait for changes and emits to the HeartBeat channel
func (m *StatusModel) Watch(ctx context.Context, algodClient *algod.Client) error {
lastRound := uint64(0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we start from 0?

Copy link
Member Author

@PhearZero PhearZero Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, it's missing it's update from the model. I will update the last round counter

@tasosbit
Copy link
Contributor

Can we change the precedence of config loading, and make the ALGORAND_DATA / disk-config parsing optional (fallback if nothing else is passed)

Currently if, say, config.json is inaccessible by the current user, the program exits early, even if I try to call with help

$ go run main.go help
FATA open /var/lib/algorand/config.json: permission denied
exit status 1

The precedence should probably be 1) arguments 2) env vars, 3) ALGORAND_DATA + parse files (only if 1 + 2 were not provided)

@PhearZero PhearZero merged commit 905dc13 into main Oct 15, 2024
@PhearZero PhearZero deleted the chore/skeleton-bubbletea-project branch October 15, 2024 12:18
HashMapsData2Value added a commit that referenced this pull request Nov 25, 2024
# This is the 1st commit message:

feat: add prompt-ui

# This is the commit message #2:

feat: configure and set algod data directory

# This is the commit message #3:

fix: RX/TX display

# This is the commit message #4:

fix: bit rate display for GB

# This is the commit message #5:

fix: configuration override order

# This is the commit message #6:

feat: handle invalid configuration and token gracefully

# This is the commit message #7:

test: fix test state

# This is the commit message #8:

fix: loading of custom endpoint address

# This is the commit message #9:

fix: loading default port

# This is the commit message #10:

test: clear viper settings

# This is the commit message #11:

fix: finds path to directory and gives cmd instruction

# This is the commit message #12:

feat: adds node start and node stop commands

# This is the commit message #13:

fix: add -y

# This is the commit message #14:

fix: turn script into indivudal commands

# This is the commit message #15:

feat: check if sudo, clarify shell

# This is the commit message #16:

chore: make more go idiomatic

# This is the commit message #17:

fix: fix proper path check

# This is the commit message #18:

fix: interact with systemctl, cleanup prompts

# This is the commit message #19:

fix: remove sudo

# This is the commit message #20:

fix: separate commands

# This is the commit message #21:

fix: proper algorand service name

# This is the commit message #22:

fix: calling with sudo

# This is the commit message #23:

chore: testing systemctl

# This is the commit message #24:

fix: checks algorand system service has been enabled directly

# This is the commit message #25:

feat: implements editAlgorandServiceFile

# This is the commit message #26:

fix: else statement

# This is the commit message #27:

fix: quick check branch

# This is the commit message #28:

fix: string template

# This is the commit message #29:

feat: adds upgrade

# This is the commit message #30:

chore: removeu nnecessary code

# This is the commit message #31:

fix: check that installed and candidate are the same

# This is the commit message #32:

chore: improve print

# This is the commit message #33:

chore: add more output

# This is the commit message #34:

fix: single quote

# This is the commit message #35:

fix: -y

# This is the commit message #36:

fix: systemctl

# This is the commit message #37:

fix: upgrade and sudo text

# This is the commit message #38:

chore: go mod tidy

# This is the commit message #39:

fix: upgrade
HashMapsData2Value added a commit that referenced this pull request Nov 25, 2024
# This is the 1st commit message:

feat: add prompt-ui

# This is the commit message #2:

feat: configure and set algod data directory

# This is the commit message #3:

fix: RX/TX display

# This is the commit message #4:

fix: bit rate display for GB

# This is the commit message #5:

fix: configuration override order

# This is the commit message #6:

feat: handle invalid configuration and token gracefully

# This is the commit message #7:

test: fix test state

# This is the commit message #8:

fix: loading of custom endpoint address

# This is the commit message #9:

fix: loading default port

# This is the commit message #10:

test: clear viper settings

# This is the commit message #11:

fix: finds path to directory and gives cmd instruction

# This is the commit message #12:

feat: adds node start and node stop commands

# This is the commit message #13:

fix: add -y

# This is the commit message #14:

fix: turn script into indivudal commands

# This is the commit message #15:

feat: check if sudo, clarify shell

# This is the commit message #16:

chore: make more go idiomatic

# This is the commit message #17:

fix: fix proper path check

# This is the commit message #18:

fix: interact with systemctl, cleanup prompts

# This is the commit message #19:

fix: remove sudo

# This is the commit message #20:

fix: separate commands

# This is the commit message #21:

fix: proper algorand service name

# This is the commit message #22:

fix: calling with sudo

# This is the commit message #23:

chore: testing systemctl

# This is the commit message #24:

fix: checks algorand system service has been enabled directly

# This is the commit message #25:

feat: implements editAlgorandServiceFile

# This is the commit message #26:

fix: else statement

# This is the commit message #27:

fix: quick check branch

# This is the commit message #28:

fix: string template

# This is the commit message #29:

feat: adds upgrade

# This is the commit message #30:

chore: removeu nnecessary code

# This is the commit message #31:

fix: check that installed and candidate are the same

# This is the commit message #32:

chore: improve print

# This is the commit message #33:

chore: add more output

# This is the commit message #34:

fix: single quote

# This is the commit message #35:

fix: -y

# This is the commit message #36:

fix: systemctl

# This is the commit message #37:

fix: upgrade and sudo text

# This is the commit message #38:

chore: go mod tidy

# This is the commit message #39:

fix: upgrade

# This is the commit message #40:

feat: disable ui elements while syncing

# This is the commit message #41:

feat: skip account loading on syncing
feat: remove offline account expires date

# This is the commit message #42:

feat: installs algod and sets up service on mac

# This is the commit message #43:

feat: refactor, + mac

# This is the commit message #44:

feat: adds uninstall, mac only

# This is the commit message #45:

fix: remove plist file

# This is the commit message #46:

chore: rename
HashMapsData2Value added a commit that referenced this pull request Nov 25, 2024
# This is the 1st commit message:

feat: add prompt-ui

# This is the commit message #2:

feat: configure and set algod data directory

# This is the commit message #3:

fix: RX/TX display

# This is the commit message #4:

fix: bit rate display for GB

# This is the commit message #5:

fix: configuration override order

# This is the commit message #6:

feat: handle invalid configuration and token gracefully

# This is the commit message #7:

test: fix test state

# This is the commit message #8:

fix: loading of custom endpoint address

# This is the commit message #9:

fix: loading default port

# This is the commit message #10:

test: clear viper settings

# This is the commit message #11:

fix: finds path to directory and gives cmd instruction

# This is the commit message #12:

feat: adds node start and node stop commands

# This is the commit message #13:

fix: add -y

# This is the commit message #14:

fix: turn script into indivudal commands

# This is the commit message #15:

feat: check if sudo, clarify shell

# This is the commit message #16:

chore: make more go idiomatic

# This is the commit message #17:

fix: fix proper path check

# This is the commit message #18:

fix: interact with systemctl, cleanup prompts

# This is the commit message #19:

fix: remove sudo

# This is the commit message #20:

fix: separate commands

# This is the commit message #21:

fix: proper algorand service name

# This is the commit message #22:

fix: calling with sudo

# This is the commit message #23:

chore: testing systemctl

# This is the commit message #24:

fix: checks algorand system service has been enabled directly

# This is the commit message #25:

feat: implements editAlgorandServiceFile

# This is the commit message #26:

fix: else statement

# This is the commit message #27:

fix: quick check branch

# This is the commit message #28:

fix: string template

# This is the commit message #29:

feat: adds upgrade

# This is the commit message #30:

chore: removeu nnecessary code

# This is the commit message #31:

fix: check that installed and candidate are the same

# This is the commit message #32:

chore: improve print

# This is the commit message #33:

chore: add more output

# This is the commit message #34:

fix: single quote

# This is the commit message #35:

fix: -y

# This is the commit message #36:

fix: systemctl

# This is the commit message #37:

fix: upgrade and sudo text

# This is the commit message #38:

chore: go mod tidy

# This is the commit message #39:

fix: upgrade

# This is the commit message #40:

feat: disable ui elements while syncing

# This is the commit message #41:

feat: skip account loading on syncing
feat: remove offline account expires date

# This is the commit message #42:

feat: installs algod and sets up service on mac

# This is the commit message #43:

feat: refactor, + mac

# This is the commit message #44:

feat: adds uninstall, mac only

# This is the commit message #45:

fix: remove plist file

# This is the commit message #46:

chore: rename

# This is the commit message #47:

test: protocol snapshots and 100%

# This is the commit message #48:

test: status snapshots and 100%

# This is the commit message #49:

test: error page snapshots and 100%

# This is the commit message #50:

test: controls snapshots

# This is the commit message #51:

test: accounts snapshots
tasosbit pushed a commit that referenced this pull request Jan 22, 2025
tasosbit pushed a commit that referenced this pull request Jan 22, 2025
# This is the 1st commit message:

feat: add prompt-ui

# This is the commit message #2:

feat: configure and set algod data directory

# This is the commit message #3:

fix: RX/TX display

# This is the commit message #4:

fix: bit rate display for GB

# This is the commit message #5:

fix: configuration override order

# This is the commit message #6:

feat: handle invalid configuration and token gracefully

# This is the commit message #7:

test: fix test state

# This is the commit message #8:

fix: loading of custom endpoint address

# This is the commit message #9:

fix: loading default port

# This is the commit message #10:

test: clear viper settings

# This is the commit message #11:

fix: finds path to directory and gives cmd instruction

# This is the commit message #12:

feat: adds node start and node stop commands

# This is the commit message #13:

fix: add -y

# This is the commit message #14:

fix: turn script into indivudal commands

# This is the commit message #15:

feat: check if sudo, clarify shell

# This is the commit message #16:

chore: make more go idiomatic

# This is the commit message #17:

fix: fix proper path check

# This is the commit message #18:

fix: interact with systemctl, cleanup prompts

# This is the commit message #19:

fix: remove sudo

# This is the commit message #20:

fix: separate commands

# This is the commit message #21:

fix: proper algorand service name

# This is the commit message #22:

fix: calling with sudo

# This is the commit message #23:

chore: testing systemctl

# This is the commit message #24:

fix: checks algorand system service has been enabled directly

# This is the commit message #25:

feat: implements editAlgorandServiceFile

# This is the commit message #26:

fix: else statement

# This is the commit message #27:

fix: quick check branch

# This is the commit message #28:

fix: string template

# This is the commit message #29:

feat: adds upgrade

# This is the commit message #30:

chore: removeu nnecessary code

# This is the commit message #31:

fix: check that installed and candidate are the same

# This is the commit message #32:

chore: improve print

# This is the commit message #33:

chore: add more output

# This is the commit message #34:

fix: single quote

# This is the commit message #35:

fix: -y

# This is the commit message #36:

fix: systemctl

# This is the commit message #37:

fix: upgrade and sudo text

# This is the commit message #38:

chore: go mod tidy

# This is the commit message #39:

fix: upgrade
tasosbit pushed a commit that referenced this pull request Jan 22, 2025
# This is the 1st commit message:

feat: add prompt-ui

# This is the commit message #2:

feat: configure and set algod data directory

# This is the commit message #3:

fix: RX/TX display

# This is the commit message #4:

fix: bit rate display for GB

# This is the commit message #5:

fix: configuration override order

# This is the commit message #6:

feat: handle invalid configuration and token gracefully

# This is the commit message #7:

test: fix test state

# This is the commit message #8:

fix: loading of custom endpoint address

# This is the commit message #9:

fix: loading default port

# This is the commit message #10:

test: clear viper settings

# This is the commit message #11:

fix: finds path to directory and gives cmd instruction

# This is the commit message #12:

feat: adds node start and node stop commands

# This is the commit message #13:

fix: add -y

# This is the commit message #14:

fix: turn script into indivudal commands

# This is the commit message #15:

feat: check if sudo, clarify shell

# This is the commit message #16:

chore: make more go idiomatic

# This is the commit message #17:

fix: fix proper path check

# This is the commit message #18:

fix: interact with systemctl, cleanup prompts

# This is the commit message #19:

fix: remove sudo

# This is the commit message #20:

fix: separate commands

# This is the commit message #21:

fix: proper algorand service name

# This is the commit message #22:

fix: calling with sudo

# This is the commit message #23:

chore: testing systemctl

# This is the commit message #24:

fix: checks algorand system service has been enabled directly

# This is the commit message #25:

feat: implements editAlgorandServiceFile

# This is the commit message #26:

fix: else statement

# This is the commit message #27:

fix: quick check branch

# This is the commit message #28:

fix: string template

# This is the commit message #29:

feat: adds upgrade

# This is the commit message #30:

chore: removeu nnecessary code

# This is the commit message #31:

fix: check that installed and candidate are the same

# This is the commit message #32:

chore: improve print

# This is the commit message #33:

chore: add more output

# This is the commit message #34:

fix: single quote

# This is the commit message #35:

fix: -y

# This is the commit message #36:

fix: systemctl

# This is the commit message #37:

fix: upgrade and sudo text

# This is the commit message #38:

chore: go mod tidy

# This is the commit message #39:

fix: upgrade

# This is the commit message #40:

feat: disable ui elements while syncing

# This is the commit message #41:

feat: skip account loading on syncing
feat: remove offline account expires date

# This is the commit message #42:

feat: installs algod and sets up service on mac

# This is the commit message #43:

feat: refactor, + mac

# This is the commit message #44:

feat: adds uninstall, mac only

# This is the commit message #45:

fix: remove plist file

# This is the commit message #46:

chore: rename
tasosbit pushed a commit that referenced this pull request Jan 22, 2025
# This is the 1st commit message:

feat: add prompt-ui

# This is the commit message #2:

feat: configure and set algod data directory

# This is the commit message #3:

fix: RX/TX display

# This is the commit message #4:

fix: bit rate display for GB

# This is the commit message #5:

fix: configuration override order

# This is the commit message #6:

feat: handle invalid configuration and token gracefully

# This is the commit message #7:

test: fix test state

# This is the commit message #8:

fix: loading of custom endpoint address

# This is the commit message #9:

fix: loading default port

# This is the commit message #10:

test: clear viper settings

# This is the commit message #11:

fix: finds path to directory and gives cmd instruction

# This is the commit message #12:

feat: adds node start and node stop commands

# This is the commit message #13:

fix: add -y

# This is the commit message #14:

fix: turn script into indivudal commands

# This is the commit message #15:

feat: check if sudo, clarify shell

# This is the commit message #16:

chore: make more go idiomatic

# This is the commit message #17:

fix: fix proper path check

# This is the commit message #18:

fix: interact with systemctl, cleanup prompts

# This is the commit message #19:

fix: remove sudo

# This is the commit message #20:

fix: separate commands

# This is the commit message #21:

fix: proper algorand service name

# This is the commit message #22:

fix: calling with sudo

# This is the commit message #23:

chore: testing systemctl

# This is the commit message #24:

fix: checks algorand system service has been enabled directly

# This is the commit message #25:

feat: implements editAlgorandServiceFile

# This is the commit message #26:

fix: else statement

# This is the commit message #27:

fix: quick check branch

# This is the commit message #28:

fix: string template

# This is the commit message #29:

feat: adds upgrade

# This is the commit message #30:

chore: removeu nnecessary code

# This is the commit message #31:

fix: check that installed and candidate are the same

# This is the commit message #32:

chore: improve print

# This is the commit message #33:

chore: add more output

# This is the commit message #34:

fix: single quote

# This is the commit message #35:

fix: -y

# This is the commit message #36:

fix: systemctl

# This is the commit message #37:

fix: upgrade and sudo text

# This is the commit message #38:

chore: go mod tidy

# This is the commit message #39:

fix: upgrade

# This is the commit message #40:

feat: disable ui elements while syncing

# This is the commit message #41:

feat: skip account loading on syncing
feat: remove offline account expires date

# This is the commit message #42:

feat: installs algod and sets up service on mac

# This is the commit message #43:

feat: refactor, + mac

# This is the commit message #44:

feat: adds uninstall, mac only

# This is the commit message #45:

fix: remove plist file

# This is the commit message #46:

chore: rename

# This is the commit message #47:

test: protocol snapshots and 100%

# This is the commit message #48:

test: status snapshots and 100%

# This is the commit message #49:

test: error page snapshots and 100%

# This is the commit message #50:

test: controls snapshots

# This is the commit message #51:

test: accounts snapshots
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants