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

Prompt for operator name #721

Merged
merged 12 commits into from
Jul 2, 2023
Merged

Conversation

artoonie
Copy link
Collaborator

@artoonie artoonie commented Jun 26, 2023

Closes #631

In GUI:
image

In CLI:
image

CLI can still work interactively if --name is specified, but the audit log will show that the name wasn't interactively entered.

Given the addition of the CLI argument, we needed the support of a framework to avoid clutter and stringent argument order.

build.gradle Show resolved Hide resolved
build.gradle Outdated Show resolved Hide resolved
if (result.isPresent()) {
Logger.info("Name(s) of operators, as entered interactively: " + result.get());
} else {
Logger.info("Operator(s) did not enter a name.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we block this / throw an exception here instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I prefer this, since when developing, I often hit tabulate a lot and can just hit cancel.

My reasoning is that we can't guarantee they'll enter a correct name, so why pretend to validate? They could enter foo instead of empty string. Just let them do empty string.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, but if that's the case, why do we force the user to provide a value in the CLI version? Shouldn't we treat this consistently?

I'm ok with allowing the user to bypass without entering a name but, if they do, we should probably log a warning (or maybe just an info) saying the user didn't provide a name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We already log an INFO that user didn't provide a name (Operator(s) did not enter a name.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can update the CLI to not fail on empty string, but I fear it's more hidden there. Especially when running via gradle, the line <===========--> 85% EXECUTING [20s] shows up after the request for a name, so it could be hidden.

In other words, empty string in CLI is more likely to be accidental, whereas in tabulation, it's more obvious.

Happy to make changes in either direction!

Copy link
Contributor

Choose a reason for hiding this comment

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

I think an argument in favor of throwing an exception / requiring this in both cases is that the user might accidentally bypass the message box with a mis-click or mis-key. I say we should go forward with it. It's really easy to just enter "asdf" when testing here anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or aoeu, depending on keyboard layout ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

Whoa whoa whoa, are you one of those? I'm impressed... 👽

src/main/java/network/brightspots/rcv/Main.java Outdated Show resolved Hide resolved
src/main/java/network/brightspots/rcv/Main.java Outdated Show resolved Hide resolved
@artoonie
Copy link
Collaborator Author

All comments addressed -- entering no name or canceling out of the name prompt cancels tabulation now

@artoonie artoonie force-pushed the feature/issue-631_prompt-for-name branch from 9f36ec8 to b475089 Compare June 27, 2023 02:26
if (result.isPresent()) {
Logger.info("Name(s) of operators, as entered interactively: " + result.get());
} else {
Logger.info("Operator(s) did not enter a name.");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think an argument in favor of throwing an exception / requiring this in both cases is that the user might accidentally bypass the message box with a mis-click or mis-key. I say we should go forward with it. It's really easy to just enter "asdf" when testing here anyway.

String name = cmd.getOptionValue("name");
boolean convertToCdf = cmd.hasOption("convert-to-cdf");

boolean validNameProvided = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I went ahead and redesigned this CLI logic so it handles corner cases more robustly. However, in doing so, I also found a critical flaw in this PR: the name that's entered and logged doesn't actually make it into the audit logs!

I think we need to make all this happen deeper in the app, i.e. immediately after this line:

Logger.info("Computer user name: %s", Utils.getUserName());

Also think it's probably fine if we don't prompt the user for their name when converting to CDF, but you could confirm with @chughes297 about this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I've made these changes: Convert to CDF doesn't require a name, and entering a blank name prevents tabulation.

@artoonie artoonie force-pushed the feature/issue-631_prompt-for-name branch from 2a1afde to 2dbc9b7 Compare June 28, 2023 18:23
Copy link
Contributor

@HEdingfield HEdingfield left a comment

Choose a reason for hiding this comment

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

Nice work! Just fixed a couple last things.

if (result.isPresent()) {
Logger.info("Name(s) of operators, as entered interactively: " + result.get());
} else {
Logger.info("Operator(s) did not enter a name.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Whoa whoa whoa, are you one of those? I'm impressed... 👽

@HEdingfield HEdingfield merged commit 316ed4a into develop Jul 2, 2023
1 check passed
@HEdingfield HEdingfield deleted the feature/issue-631_prompt-for-name branch July 2, 2023 07:11
@tarheel
Copy link
Contributor

tarheel commented Jul 9, 2023

Whoa whoa whoa, are you one of those? I'm impressed... 👽

I heard that truly 3lit3 engineers only use Colemak.

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

Successfully merging this pull request may close these issues.

Login Feature to Track Users
3 participants