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

arkd cli flags update #424

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sekulicd
Copy link
Collaborator

The provided code changes introduce several modifications to the arkd command-line interface, primarily focusing on refactoring and improving the handling of flags and paths for macaroons and TLS certificates. Here's a summary of the key changes:

  1. Flag Refactoring:

    • Flag names have been moved to constants for better maintainability and readability. For example, "url" is now flagURL, and "password" is now flagPassword.
    • This change ensures that flag names are consistently used throughout the code and makes it easier to modify them if needed in the future.
  2. New Function for Credential Paths:

    • A new function getCredentialPaths(ctx *cli.Context) is introduced. This function centralizes the logic for determining the paths of macaroons and TLS certificates.
    • It checks if the application should use a macaroon (based on its presence) and adjusts the TLS certificate path if the URL is HTTP instead of HTTPS.
  3. Simplification of Command Actions:

    • The command actions (walletStatusAction, walletCreateOrRestoreAction, walletUnlockAction, walletAddressAction, walletBalanceAction, and createNoteAction) now use the getCredentialPaths function to fetch the macaroon and TLS certificate paths, reducing repetitive code.
    • This change simplifies each action by removing the inline logic for path handling and error checking related to credentials.
  4. Removal of Unused Flags:

    • Flags that were previously used for specifying macaroon paths and TLS certificate paths directly (noMacaroonFlag, macaroonFlag, and tlsCertFlag) have been removed. Instead, a single datadirFlag is used to specify the directory containing these files.
    • This change reduces the complexity of the command-line interface by minimizing the number of flags users need to manage.
  5. Use of Path Joining for File Paths:

    • The filepath.Join function is used to construct file paths for macaroons and TLS certificates, ensuring cross-platform compatibility and correctness of file paths.
  6. Code Organization:

    • The code is reorganized to improve readability, with related constants grouped together and helper functions extracted for clarity.

Overall, these changes aim to streamline the configuration and execution of commands by centralizing the handling of credentials and using a more structured approach to defining and using flags. This refactoring should improve both the maintainability of the code and the user experience when interacting with the command-line interface.

@altafan please review.

server/cmd/arkd/main.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants