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

Avoid code repetition among import and import_list #16

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

Conversation

jvfe
Copy link
Collaborator

@jvfe jvfe commented Apr 10, 2022

qs = render_orcid_qs(orcid)
@click.option(
"--orcids",
prompt="ORCID ID or a path to list of ORCID IDs",
Copy link
Collaborator

Choose a reason for hiding this comment

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

HIGHLY suggest against doing this. Each option in a non-insane CLI should correspond to one datatype only. Just make two different options or two different CLIs if they have different semantics

Copy link
Owner

Choose a reason for hiding this comment

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

I do not have enough experience here; I'll just leave it open for now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's actually a great point, @cthoyt. I've read the same advice before but it still didn't cross my mind. My main worry in this case is to avoid unnecessary code repetition, but I'll refactor it as soon as I can. Thank you!

@jvfe jvfe marked this pull request as draft April 11, 2022 17:01
- Instead of repeating code between import info from list and import
  info, include a type guard on import_info to check if the argument
provided is a path or a just a string.

- Addresses lubianat#14
- Keeps both commands, but refactors repeated functionality into a
  separate function.
- Also improves the way the path to the ORCID file is read
- Also adds missing open_browser to import_list

- Closes lubianat#14
- This way the same option code isn't repeated between modules, it's
  merely passed down as context
- Open browser can now be called as:
`pyorcidator --open-browser import --orcid ORCID_ID`
@jvfe jvfe marked this pull request as ready for review April 15, 2022 12:50
@jvfe
Copy link
Collaborator Author

jvfe commented Apr 15, 2022

Following the great suggestion by @cthoyt I've kept the options separate but I've also kept them as separate commands - while externalizing the code they shared to a separate utility function, just so the code isn't repeated, which was my original intention. I'll change this PR's title to reflect these updates.

@jvfe jvfe changed the title Unite orcid list & single orcid function into single import function Avoid code repetition among import and import_list Apr 15, 2022
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.

Avoid code repetition between import_info and import_info_from_list
3 participants