While I usually like explicitly setting all values, getting rid of
setting the empty string streamlines map construction and testing.
The reasonsMap will return the nil value because the empty string is not
in the map.
I noticed that PadlockState didn't really have anything to do with the
LockOptions and it was easy to call an incorrect locking function that
didn't match the PadlockState.
Now, you pass in the state as an argument and you simply call the
appropriate function instead of setting PadlockState and then calling
the correct function.
- Other touch ups and refactoring
Rather than saving the intended lock state and calling a method
depending on the lock state, just call the method directly. By the time
you need to the padlock state, you already know which method to use; no
need to first change the lock state than call the method.
Also, refactored print/error messages that are conditional.
- Fix error if found an issue while using `gh pr lock/unlock` or vice versa
- Added additional types
- Used githubv4 types
- Added "relock" state
- If the conversation is already locked you have two choices: try to
lock it again or do nothing. Do nothing is easy. But, if you
want to change the lock reason, you need to first unlock the
conversation and then lock it again.
- Added survey to confirm if you want to relock
- Added formatted print statements
- Changed function to method
- Moved additional common options to method
- Remove redundant documentation
- Cobra sets documentation in the Command struct.
As originally designed in the issue discussion, a single function
`NewCmdLock()` with a parameter to lock or unlock was proposed.
However, after playing around with a couple different designs, it seems
best to create two separate public functions and one private function to
do the common work.
Using two public functions seems to make sense because the api for
locking is different from the api for unlocking. Therefore, the
documentation for both are different and keeping them in separate
functions would make it easier to maintain the documentation.