AtlatestRepositorysigil-web-styles
1
2# Getting Started
3
4> Creating new Sigil projects with `sigil init`.
5
6## Creating a New Project
7
8Use `sigil init` to create a new project:
9
10```bash
11sigil init my-project
12```
14This creates a new directory `my-project/` with a basic project structure.
16## Project Templates
18Sigil provides several templates for different project types:
20```bash
21sigil init my-app # Application with entry point (default template)
22sigil init my-lib --template library # Reusable library with exports
23sigil init my-cli --template cli # Command-line tool with argument parsing
24sigil init my-game --template game # Game project with graphics/audio setup
25```
27### Template: default
29Creates a simple application:
31```
32my-app/
33├── package.sgl # Package definition
34├── README.md # Project documentation
35└── src/
36 └── my-app/
37 └── main.sgl # Entry point module
38```
40### Template: library
42Creates a library package:
44```
45my-lib/
46├── package.sgl
47├── README.md
48├── src/
49│ └── my-lib.sgl # Main library module
50└── test/
51 └── test-my-lib.sgl
52```
54### Template: cli
56Creates a CLI application with argument parsing:
58```
59my-cli/
60├── package.sgl
61├── README.md
62└── src/
63 └── my-cli/
64 └── main.sgl # CLI with sigil/args
65```
67## Package File Format
69The `package.sgl` file defines your project:
71```scheme
72(package
73 name: "my-app"
74 version: "0.1.0"
75 description: "My application"
76 license: "MIT"
78 ;; Entry point for executable apps
79 ;; The module must export a 'main' procedure
80 entry: '(my-app main)
82 ;; Dependencies from the Sigil ecosystem
83 dependencies: (list
84 (from-workspace name: "sigil-stdlib")))
85```
87### Entry Point
89The `entry:` field specifies which module to run when the application starts:
91- Format: `'(module-name)` - a quoted list of symbols representing the module
92- The module must export a `main` procedure that takes no arguments
93- Example: `entry: '(my-app main)` runs the `main` procedure from `(my-app main)` module
95### Module Naming Convention
97Module names follow the directory structure under `src/`:
99| File Path | Module Name |
100|-----------|-------------|
101| `src/my-app/main.sgl` | `(my-app main)` |
102| `src/my-app.sgl` | `(my-app)` |
103| `src/my-app/utils.sgl` | `(my-app utils)` |
105## Running Your Project
107After creating a project:
109```bash
110cd my-project
111sigil run # Build and run the app
112sigil test # Run tests (if any)
113```
115The `sigil run` command automatically builds any out-of-date modules before running.
117For a release build (standalone executable):
119```bash
120sigil build --config release # Create release build
121./build/release/bin/my-project # Run the release build
122```
124## Example: Hello World Application
126```bash
127sigil init hello-world
128cd hello-world
129```
131Edit `src/hello-world/main.sgl`:
133```scheme
134(define-library (hello-world main)
135 (export main)
136 (begin
137 (define (main)
138 (println "Hello, World!"))))
139```
141Build and run:
143```bash
144sigil run
145# Output: Hello, World!
146```