Skip to content

Commit 338640f

Browse files
feat(examples): CLI interface improvements
changes: - file: cli.py area: cli modified: [main] - file: config.py area: config added: [get_project_name] modified: [Config] dependencies: flow: "cli→config" - cli.py -> config.py stats: lines: "+51/-7 (net +44)" files: 3 complexity: "Large structural change (normalized)"
1 parent aa98c4c commit 338640f

File tree

11 files changed

+71
-14
lines changed

11 files changed

+71
-14
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ CODE2LOGIC_DEFAULT_PROVIDER=ollama
4343
# Default model (overrides provider-specific model)
4444
# CODE2LOGIC_DEFAULT_MODEL=
4545

46+
# Default project name (used for output files like project.toon, project.functions.toon)
47+
CODE2LOGIC_PROJECT_NAME=project
48+
4649
# Verbose logging
4750
CODE2LOGIC_VERBOSE=false
4851

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## [1.0.34] - 2026-02-24
2+
3+
### Summary
4+
5+
feat(examples): CLI interface improvements
6+
7+
### Other
8+
9+
- update .env.example
10+
- update code2logic/cli.py
11+
- update code2logic/config.py
12+
13+
114
## [1.0.33] - 2026-02-23
215

316
### Summary

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.33
1+
1.0.34

code2logic/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
>>> print(output)
1919
"""
2020

21-
__version__ = "1.0.33"
21+
__version__ = "1.0.34"
2222
__author__ = "Softreck"
2323
__email__ = "info@softreck.dev"
2424
__license__ = "MIT"

code2logic/cli.py

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

code2logic/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ def is_verbose(self) -> bool:
153153
"""Check if verbose mode is enabled."""
154154
return os.environ.get('CODE2LOGIC_VERBOSE', '').lower() in ('true', '1', 'yes')
155155

156+
def get_project_name(self) -> str:
157+
"""Get default project name for output files.
158+
159+
Returns:
160+
Project name (default: 'project')
161+
"""
162+
return os.environ.get('CODE2LOGIC_PROJECT_NAME', 'project')
163+
156164
def get_cache_dir(self) -> Path:
157165
"""Get cache directory path."""
158166
cache_dir = os.environ.get('CODE2LOGIC_CACHE_DIR', '~/.code2logic/cache')

logic2code/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
from .generator import CodeGenerator, GeneratorConfig, GenerationResult
1515
from .renderers import PythonRenderer
1616

17-
__version__ = '1.0.33'
17+
__version__ = '1.0.34'
1818
__all__ = ['CodeGenerator', 'GeneratorConfig', 'GenerationResult', 'PythonRenderer']

logic2test/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
from .parsers import LogicParser
1616
from .templates import TestTemplate
1717

18-
__version__ = '1.0.33'
18+
__version__ = '1.0.34'
1919
__all__ = ['TestGenerator', 'GeneratorConfig', 'GenerationResult', 'LogicParser', 'TestTemplate']

lolm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
)
7777
from .clients import LLMRateLimitError
7878

79-
__version__ = '1.0.33'
79+
__version__ = '1.0.34'
8080
__all__ = [
8181
# Config
8282
'LLMConfig',

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "code2logic"
7-
version = "1.0.33"
7+
version = "1.0.34"
88
description = "Code2Logic - Source code to logical representation converter for LLM analysis, featuring Tree-sitter parsing, dependency graph analysis, and multi-language support."
99
readme = "README.md"
1010
license = "Apache-2.0"

0 commit comments

Comments
 (0)