1- #!/usr/bin/env python3
21import argparse
32import sys
43import os
54import traceback
6- from rocrate .datasheet_generator import DatasheetGenerator
5+ from pathlib import Path
6+
7+ from fairscape_cli .datasheet_builder .rocrate .datasheet_generator import DatasheetGenerator
8+
79
810def main ():
911 parser = argparse .ArgumentParser (
@@ -14,28 +16,51 @@ def main():
1416 required = True ,
1517 help = 'Path to top-level ro-crate-metadata.json file'
1618 )
19+ parser .add_argument (
20+ '--templates' ,
21+ default = './templates' ,
22+ help = 'Path to templates directory (default: ./templates)'
23+ )
24+ parser .add_argument (
25+ '--output' ,
26+ help = 'Path for output datasheet HTML (default: same dir as input)'
27+ )
28+ parser .add_argument (
29+ '--published' ,
30+ action = 'store_true' ,
31+ help = 'Generate published version with fairscape.net links'
32+ )
33+
1734 args = parser .parse_args ()
1835
1936 try :
20- input_dir = os .path .dirname (args .input )
21- template_dir = "./templates"
22- output_path = os .path .join (input_dir , "ro-crate-datasheet.html" )
37+ input_path = Path (args .input )
38+ input_dir = input_path .parent
39+ template_dir = Path (args .templates )
40+
41+ if args .output :
42+ output_path = Path (args .output )
43+ else :
44+ output_path = input_dir / "ro-crate-datasheet.html"
2345
2446 generator = DatasheetGenerator (
25- json_path = args .input ,
26- template_dir = template_dir
47+ json_path = input_path ,
48+ template_dir = template_dir ,
49+ published = args .published
2750 )
2851
2952 generator .process_subcrates ()
3053
3154 final_output_path = generator .save_datasheet (output_path )
3255 print (f"Datasheet generated successfully: { final_output_path } " )
56+
3357 except Exception as e :
3458 print (f"Error: { str (e )} " )
3559 traceback .print_exc ()
3660 return 1
3761
3862 return 0
3963
64+
4065if __name__ == "__main__" :
4166 sys .exit (main ())
0 commit comments