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

UI Improvements & Refactoring #8

Merged
merged 1 commit into from
Nov 22, 2021
Merged

Conversation

arcanericky
Copy link
Contributor

UI Improvements & Refactoring

The biggest UI improvement is the use of the
prompui package
for consuming user input. It's more interactive and performs
dynamic validation.

The UI now allows the user to select the encryption type from a list
if the encryption option is invalid or an empty option is specified
with -enc=. As before, if no encryption option is given, it defaults
to WPA2 and the user is not prompted for the encryption type. I've tried
to make these improvements without breaking the old UI flow (yet). One
difference is invalid encryption protocols were allowed, but now they
are limited to valid types.

The main package has been mostly refactored. The highlights include:

  • Extraction of code to smaller functions to improvement maintainability,
    readability and hopefully to help accommodate future unit tests.
  • Move code in main to a new run function that returns an exit code.
    (Helps with future unit tests)
  • Remove the use of all global variables except injected version.
  • DRY the code.
    • SSID/password descriptions
    • .png extension
    • Validation code
  • Improve user facing text consistency.
  • Consistent use of error returns.
  • Validation of SSID maximum length.
  • Validation of encryption option.
  • Some unit test coverage.

The core package now contains the type EncryptionType to help limit
the input into the API and make the strings consistent. This particular
implementation isn't ideal but works for now.

Minor edits made to the README, mostly to conform to
markdownlint.

Note this PR changes the API a bit, but since it's a v0.x.x series of
releases, I've assumed that's ok. The encryption protocol has changed
from a type of string to EncryptionProtocol for both NewConfig
and the Config struct.

Unit testing will require a bit of dependency injection but before going
through that, it'll be good to see how far this PR goes since I know it's
unsolicited.

@reugn
Copy link
Owner

reugn commented Nov 21, 2021

Hi @arcanericky, thanks for the improvements. This looks good. I'll take a closer look at the PR soon.

@reugn
Copy link
Owner

reugn commented Nov 22, 2021

Looks great. My only concern is the BSD-3 license of the promptui library.

Copy link
Owner

@reugn reugn left a comment

Choose a reason for hiding this comment

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

Checked that. The same license as Golang. Merging.

@reugn reugn merged commit 5eb290c into reugn:develop Nov 22, 2021
@arcanericky arcanericky deleted the ui-refactor branch November 30, 2021 15:31
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