@@ -608,6 +608,11 @@ def _maybe_print_pretty_help() -> bool:
608608 '-o' , '--output' ,
609609 help = 'Output file path (default: stdout)'
610610 )
611+ parser .add_argument (
612+ '--name' ,
613+ dest = 'project_name' ,
614+ help = 'Project name for output files (default: from CODE2LOGIC_PROJECT_NAME env or "project"). Used for auto-generating output, schema, and function-logic file names.'
615+ )
611616 parser .add_argument (
612617 '--function-logic' ,
613618 nargs = '?' ,
@@ -725,6 +730,7 @@ def _maybe_print_pretty_help() -> bool:
725730
726731 # Import after potential installation
727732 from .analyzer import ProjectAnalyzer , get_library_status
733+ from .config import Config
728734 from .function_logic import FunctionLogicGenerator
729735 from .generators import (
730736 CSVGenerator ,
@@ -736,6 +742,9 @@ def _maybe_print_pretty_help() -> bool:
736742 from .logicml import LogicMLGenerator
737743 from .toon_format import TOONGenerator
738744
745+ # Load config to get project name
746+ config = Config ()
747+
739748 # Status check
740749 if args .status :
741750 status = get_library_status ()
@@ -844,6 +853,27 @@ def _maybe_print_pretty_help() -> bool:
844853
845854 log .separator ()
846855
856+ # Get default project name from config
857+ project_name = config .get_project_name ()
858+
859+ # Determine default output path when using --function-logic or --with-schema without -o
860+ default_output = None
861+ if (args .function_logic or args .with_schema ) and not args .output :
862+ # Use project name from config with appropriate extension
863+ ext_map = {
864+ 'markdown' : 'md' ,
865+ 'compact' : 'txt' ,
866+ 'json' : 'json' ,
867+ 'yaml' : 'yaml' ,
868+ 'hybrid' : 'yaml' ,
869+ 'csv' : 'csv' ,
870+ 'gherkin' : 'feature' ,
871+ 'toon' : 'toon' ,
872+ 'logicml' : 'logicml' ,
873+ }
874+ ext = ext_map .get (args .format , args .format )
875+ default_output = f"{ project_name } .{ ext } "
876+
847877 # Generate output
848878 if args .verbose :
849879 log .step (f"Generating { args .format } output (detail: { args .detail } )" )
@@ -883,7 +913,8 @@ def _maybe_print_pretty_help() -> bool:
883913 schema = generator .generate_schema ('hybrid' )
884914 else :
885915 schema = generator .generate_schema ('compact' if compact else 'full' )
886- base_name = os .path .splitext (args .output )[0 ] if args .output else 'output'
916+ effective_output = args .output or default_output
917+ base_name = os .path .splitext (effective_output )[0 ] if effective_output else project_name
887918 schema_path = f"{ base_name } .yaml-schema.json"
888919 parent_dir = os .path .dirname (schema_path )
889920 if parent_dir :
@@ -916,7 +947,8 @@ def _maybe_print_pretty_help() -> bool:
916947 if args .with_schema :
917948 schema_type = 'ultra_compact' if use_ultra_compact else 'standard'
918949 schema = generator .generate_schema (schema_type )
919- base_name = os .path .splitext (args .output )[0 ] if args .output else 'output'
950+ effective_output = args .output or default_output
951+ base_name = os .path .splitext (effective_output )[0 ] if effective_output else project_name
920952 schema_path = f"{ base_name } .toon-schema.json"
921953 parent_dir = os .path .dirname (schema_path )
922954 if parent_dir :
@@ -940,18 +972,19 @@ def _maybe_print_pretty_help() -> bool:
940972
941973 # Auto-generate path if 'auto' was specified (--function-logic without argument)
942974 if args .function_logic == 'auto' :
943- if args .output :
975+ effective_output = args .output or default_output
976+ if effective_output :
944977 # Derive from output file: project.c2l.yaml -> project.functions.yaml
945- base = args . output .rsplit ('.' , 1 )[0 ]
978+ base = effective_output .rsplit ('.' , 1 )[0 ]
946979 if base .endswith ('.c2l' ):
947980 base = base [:- 4 ]
948- ext = args . output . rsplit ('.' , 1 )[- 1 ] if '.' in args . output else 'logicml'
981+ ext = effective_output . rsplit ('.' , 1 )[- 1 ] if '.' in effective_output else 'logicml'
949982 logic_path = f"{ base } .functions.{ ext } "
950983 else :
951- # Default path based on format
984+ # Default path based on format using project name from config
952985 ext_map = {'json' : 'json' , 'yaml' : 'yaml' , 'toon' : 'toon' }
953986 ext = ext_map .get (args .format , 'logicml' )
954- logic_path = f"project .functions.{ ext } "
987+ logic_path = f"{ project_name } .functions.{ ext } "
955988 else :
956989 logic_path = str (args .function_logic )
957990
0 commit comments