cmd/juno: add filepath support for p2p CLI
Description
This PR adds filepath support to two existing P2P-related tools and flags, namely genp2pkeypair and --p2p-private-key.
Example
Command: juno genp2pkeypair --file nodekey
- This would generate a file containing the key pairs information.
- Note that users can still do
juno genp2pkeypairjust like before.
Command: juno --p2p-private-key nodekey
- This would read the private key given in the
nodekeyfile. - Note that users can also just parse the private key (i.e.
juno --p2p-private-key <private-key>) just like before. - The content of the file should either be just the private key or contains the "P2P Private Key:" prefix. Examples are shown below:
# Example 1: Pure private key
<private-key>
# Example 2: With prefix
P2P Private Key: <private-key>
Rationale
It's more of a UX nicety to allow users to generate key pairs in a file and parse the file to use as a private key, rather than having to copy pasting manually.
Codecov Report
Attention: Patch coverage is 70.00000% with 9 lines in your changes missing coverage. Please review.
Project coverage is 75.44%. Comparing base (
a30d388) to head (2abdcd9). Report is 41 commits behind head on main.
| Files | Patch % | Lines |
|---|---|---|
| cmd/juno/juno.go | 53.33% | 4 Missing and 3 partials :warning: |
| cmd/juno/genp2pkeypair.go | 86.66% | 1 Missing and 1 partial :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #1904 +/- ##
==========================================
- Coverage 75.51% 75.44% -0.08%
==========================================
Files 100 100
Lines 8982 9003 +21
==========================================
+ Hits 6783 6792 +9
- Misses 1599 1605 +6
- Partials 600 606 +6
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
On a second thought, I find this feature irrelevant as users can just use environment variables.