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

feat: allow output to various machine-readable formats #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dmaljovec
Copy link

Closes #33

@dmaljovec
Copy link
Author

Caveat, I added no tests, but happy to do so if there is some direction here.

@dmaljovec
Copy link
Author

Example usage of the new feature:

$ libyear --help
usage: libyear [-h] [-r R] [--sort] [-f {text,json,csv}]

options:
  -h, --help            show this help message and exit
  -r R                  Requirements file/path
  --sort                Sort by years behind, in descending order
  -f {text,json,csv}, --format {text,json,csv}
                        The output format to use (default: text)
$ libyear -r test_requirements.txt        
+---------+-----------------+----------------+-----------------+
| Library | Current Version | Latest Version | Libyears behind |
+---------+-----------------+----------------+-----------------+
|  pytest |     7.0.0rc1    |     7.4.0      |       1.54      |
+---------+-----------------+----------------+-----------------+
Your system is 1.54 libyears behind
$ libyear -f json -r test_requirements.txt
[
    [
        "Library",
        "Current Version",
        "Latest Version",
        "Libyears behind"
    ],
    {
        "Current Version": "7.0.0rc1",
        "Latest Version": "7.4.0",
        "Library": "pytest",
        "Libyears behind": "1.54"
    }
]
$ libyear --format csv -r test_requirements.txt
Library,Current Version,Latest Version,Libyears behind
pytest,7.0.0rc1,7.4.0,1.54
$ libyear --format yaml -r test_requirements.txt
usage: libyear [-h] [-r R] [--sort] [-f {text,json,csv}]
libyear: error: argument -f/--format: invalid Format value: 'yaml'

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.

Output to computer-readable formats
1 participant