11from pathlib import Path
22from typing import Annotated
33
4+ import humanize
45import typer
6+ from rich import print
7+ from rich .console import Console
58from rich .progress import (
69 BarColumn ,
710 MofNCompleteColumn ,
1215 TimeElapsedColumn ,
1316 TimeRemainingColumn ,
1417)
18+ from rich .table import Table
1519
1620from northlighttools .rmdp .enumerators .endianness import Endianness , EndiannessChoice
1721from northlighttools .rmdp .enumerators .package_version import (
@@ -55,15 +59,15 @@ def info(
5559 )
5660 package = Package (header_path = bin_path )
5761
58- typer .echo (f"Endianness: { package .endianness } " )
59- typer .echo (f"Version: { package .version .name } ({ package .version .value } )" )
60- typer .echo (f"Number of folders: { len (package .folders )} " )
61- typer .echo (f"Number of files: { len (package .files )} " )
62+ print (f"Endianness: { package .endianness } ({ package .endianness .name .title ()} )" )
63+ print (
64+ f"Version: { package .version } ({ package .version .name .replace ('_' , ' ' ).title ()} )"
65+ )
66+ print (f"Number of folders: { len (package .folders )} " )
67+ print (f"Number of files: { len (package .files )} " )
6268
6369 if print_unknown_metadata :
64- typer .echo ("Unknown metadata:" )
65- for key , value in package .unknown_data .items ():
66- typer .echo (f" { key } : { value } " )
70+ print ("Unknown metadata:" , package .unknown_data )
6771
6872
6973@app .command (name = "list" , help = "Lists files in a Remedy Package" )
@@ -79,6 +83,7 @@ def contents(
7983 ),
8084 ],
8185):
86+ console = Console ()
8287 bin_path , _ = get_archive_paths (archive_path )
8388
8489 with Progress (transient = True ) as progress :
@@ -88,9 +93,17 @@ def contents(
8893 )
8994 package = Package (header_path = bin_path )
9095
96+ table = Table ("File Path" , "Size" , "Offset" )
97+
9198 for file in package .files :
9299 file_path = package .get_file_path (file )
93- typer .echo (f"{ file_path } (Size: { file .size } bytes, Offset: { file .offset } )" )
100+ table .add_row (
101+ str (file_path ),
102+ humanize .naturalsize (file .size ),
103+ hex (file .offset ),
104+ )
105+
106+ console .print (table )
94107
95108
96109@app .command (help = "Extracts a Remedy Package" )
@@ -127,27 +140,26 @@ def extract(
127140 )
128141 package = Package (header_path = bin_path )
129142
130- progress = Progress (
131- SpinnerColumn (finished_text = "\u2713 " ),
143+ with Progress (
144+ SpinnerColumn (finished_text = ":white_check_mark: " ),
132145 TextColumn ("[progress.description]{task.description}" ),
133146 BarColumn (),
134147 MofNCompleteColumn (),
135148 TaskProgressColumn (),
136149 TimeElapsedColumn (),
137150 TimeRemainingColumn (),
138- )
139-
140- with progress and rmdp_path .open ("rb" ) as f :
141- for file in progress .track (
142- package .files ,
143- description = "Extracting files..." ,
144- ):
145- file_path = package .get_file_path (file )
146- output_path = output_dir / file_path
151+ ) as progress :
152+ with rmdp_path .open ("rb" ) as f :
153+ for file in progress .track (
154+ package .files ,
155+ description = "Extracting files..." ,
156+ ):
157+ file_path = package .get_file_path (file )
158+ output_path = output_dir / file_path
147159
148- progress .console .log (f"Extracting { file_path } ..." )
160+ progress .console .log (f"Extracting { file_path } ..." )
149161
150- package .extract (f , file , output_path )
162+ package .extract (f , file , output_path )
151163
152164
153165@app .command (help = "Pack directory into a Remedy Package" )
@@ -195,21 +207,19 @@ def pack(
195207 bin_path = output_dir .with_suffix (".bin" )
196208 rmdp_path = output_dir .with_suffix (".rmdp" )
197209
198- progress = Progress (
199- SpinnerColumn (finished_text = "\u2713 " ),
210+ package = Package ()
211+ package .endianness = Endianness [endianness .name .upper ()]
212+ package .version = PackageVersion (int (version ))
213+
214+ with Progress (
215+ SpinnerColumn (finished_text = ":white_check_mark:" ),
200216 TextColumn ("[progress.description]{task.description}" ),
201217 BarColumn (),
202218 MofNCompleteColumn (),
203219 TaskProgressColumn (),
204220 TimeElapsedColumn (),
205221 TimeRemainingColumn (),
206- )
207-
208- package = Package ()
209- package .endianness = Endianness [endianness .name .upper ()]
210- package .version = PackageVersion (int (version ))
211-
212- with progress :
222+ ) as progress :
213223 with rmdp_path .open ("wb" ) as rmdp_file :
214224 for path in progress .track (
215225 sorted (input_dir .rglob ("*" )),
0 commit comments