Describe what you want in an intent file; the compiler uses Claude to write the code.

0 downloads

Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-compiler.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-compiler.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-compiler.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 Add context files - the header files of intent compilation 114b162 1 year, 1 month ago History
cli.py · 1.6 KB · 61 lines
1#!/usr/bin/env python3
2"""
3DBBasic-Compiler CLI
4
5The command-line interface for the intelligent compiler.
6"""
7
8import sys
9from .compiler import AICompiler
10
11
12def main():
13 """Main entry point for dbbasic-compile command."""
14 if len(sys.argv) < 2:
15 print("DBBasic-Compiler - The compiler that understands English")
16 print()
17 print("Usage:")
18 print(" dbbasic-compile <intent_file> # Compile intent to code")
19 print(" dbbasic-compile run <program_name> # Run compiled program")
20 print(" dbbasic-compile list # List compiled programs")
21 print()
22 print("Example:")
23 print(" dbbasic-compile myapp.intent.md")
24 print(" dbbasic-compile run myapp")
25 print()
26 print("Environment:")
27 print(" ANTHROPIC_API_KEY must be set")
28 print()
29 print("Get your API key: https://console.anthropic.com/")
30 return 1
31
32 command = sys.argv[1]
33
34 try:
35 compiler = AICompiler()
36 except ValueError as e:
37 print(f"Error: {e}")
38 return 1
39
40 # Handle 'list' command
41 if command == "list":
42 compiler.list_programs()
43 return 0
44
45 # Handle 'run' command
46 if command == "run":
47 if len(sys.argv) < 3:
48 print("Usage: dbbasic-compile run <program_name>")
49 return 1
50 program_name = sys.argv[2]
51 success = compiler.run(program_name)
52 return 0 if success else 1
53
54 # Otherwise treat first arg as intent file to compile
55 intent_file = command
56 success = compiler.compile(intent_file)
57 return 0 if success else 1
58
59
60if __name__ == "__main__":
61 sys.exit(main())