-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add a command line interface #109
Open
greglucas
wants to merge
7
commits into
medley56:main
Choose a base branch
from
greglucas:cli-start
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+493
−257
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This refactors out the reading of a byte-stream into a separate generator function that can yield raw CCSDSPackets with only a header and the raw bytes. The definitions and parsing logic can use this generator to yield packets and then parse whatever they need to after the fact. This enables someone to use this generator without a packet definition and to investigate what is in the packet stream without needing to know more detailed information about how individual packets are laid out internally.
…ts.py This makes the packets.py the defacto generator and able to be called with a definition file as input rather than needing to instantiate the generator from the definition itself.
I decided to give You can test it out locally with these commands (with color locally): spp describe-packets tests/test_data/idex/sciData_2023_052_14_45_05
tests/test_data/idex/sciData_2023_052_14_45_05: 78 packets
┏━━━━━━━━━┳━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┓
┃ VERSION ┃ TYPE ┃ SEC_HDR_FLG ┃ PKT_APID ┃ SEQ_FLGS ┃ SRC_SEQ_CTR ┃ PKT_LEN ┃
┡━━━━━━━━━╇━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━┩
│ 0 │ 0 │ 1 │ 1424 │ 3 │ 0 │ 297 │
│ 0 │ 0 │ 1 │ 1424 │ 3 │ 1 │ 4073 │
│ 0 │ 0 │ 1 │ 1424 │ 3 │ 2 │ 4073 │
│ 0 │ 0 │ 1 │ 1424 │ 3 │ 3 │ 2901 │
│ 0 │ 0 │ 1 │ 1424 │ 3 │ 4 │ 4073 │
│ ... │ ... │ ... │ ... │ ... │ ... │ ... │
│ 0 │ 0 │ 1 │ 1424 │ 3 │ 73 │ 4073 │
│ 0 │ 0 │ 1 │ 1424 │ 3 │ 74 │ 2901 │
│ 0 │ 0 │ 1 │ 1424 │ 3 │ 75 │ 1065 │
│ 0 │ 0 │ 1 │ 1424 │ 3 │ 76 │ 1065 │
│ 0 │ 0 │ 1 │ 1424 │ 3 │ 77 │ 1065 │
└─────────┴──────┴─────────────┴──────────┴──────────┴─────────────┴─────────┘
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a very basic command line interface and prints the header contents of a file to the terminal. I figured this would be easier to discuss as a prototype rather than opening an issue.
I've currently implemented this with just basic built-in argparse utilities, but I'm wondering if we should add some other dependencies to make the cli a little nicer? The two that have caught my eye are:
I don't keep up with all of the cli/formatting libraries, so if there are others I should look at let me know. These libraries don't have any other dependencies which is nice as well, so they would each only add their dependency and they are both lightweight and heavily used.
Example of the current output, which could definitely be spruced up and made to look nicer, but I wanted to just put this up quick as an example to get feedback on the approach.
Checklist