-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""Command-line interface for IGEL filesystem operations.""" | ||
|
||
import json | ||
from argparse import ArgumentParser | ||
from pprint import pprint | ||
|
||
from igelfs.filesystem import Filesystem | ||
from igelfs.lxos import LXOSParser | ||
|
||
|
||
def get_parser() -> ArgumentParser: | ||
"""Return argument parser instance.""" | ||
parser = ArgumentParser( | ||
prog="igelfs", | ||
description="Python implementation of the IGEL filesystem", | ||
epilog="Copyright (C) 2024 Zack Didcott", | ||
) | ||
parser.add_argument("path", help="path to the IGEL filesystem image") | ||
parser.add_argument("--inf", help="path to lxos.inf configuration file") | ||
parser.add_argument("--json", action="store_true", help="format result as JSON") | ||
return parser | ||
|
||
|
||
def main() -> None: | ||
"""Main entry-point for command-line interface.""" | ||
parser = get_parser() | ||
args = parser.parse_args() | ||
filesystem = Filesystem(args.path) | ||
lxos_config = LXOSParser(args.inf) if args.inf else None | ||
info = filesystem.get_info(lxos_config) | ||
if args.json: | ||
print(json.dumps(info)) | ||
else: | ||
pprint(info) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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 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