Skip to content

Commit ac6deff

Browse files
Eduardo SilvaMartin Verzilli
Eduardo Silva
authored and
Martin Verzilli
committedMay 23, 2017
Add man page to crystal (#2989)
1 parent 241dbc2 commit ac6deff

File tree

1 file changed

+237
-0
lines changed

1 file changed

+237
-0
lines changed
 

‎man/crystal.1

+237
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
.\"Crystal Programming Language
2+
.Dd
3+
.Dt CRYSTAL(1) "" "Crystal Compiler Command Line Reference Guide"
4+
.\".Dt CRYSTAL 1
5+
.Os UNIX
6+
.Sh NAME
7+
.Nm crystal
8+
.Nd Compiler for the Crystal language.
9+
.Sh SYNOPSYS
10+
.Nm
11+
command
12+
.Op switches
13+
programfile
14+
--
15+
.Op arguments
16+
.Sh DESCRIPTION
17+
Crystal is a statically type-checked programming language. It was created with the beauty of Ruby and the performance of C in mind.
18+
.Sh USAGE
19+
You can compile and run a program by invoking the compiler with a single filename:
20+
.Bd -offset indent-two
21+
.Nm
22+
some_program.cr
23+
.Ed
24+
25+
Crystal files usually end with the .cr extension, though this is not mandatory.
26+
27+
Alternatively you can use the run command:
28+
.Bd -offset indent-two
29+
.Nm
30+
run
31+
some_program.cr
32+
.Ed
33+
34+
To create an executable use the build command:
35+
.Bd -offset indent-two
36+
.Nm
37+
build
38+
some_program.cr
39+
.Ed
40+
41+
This will create an executable named "some_program".
42+
43+
Note that by default the generated executables are not fully optimized.
44+
To turn optimizations on, use the --release flag:
45+
.Bd -offset indent-two
46+
.Nm
47+
--release
48+
build
49+
some_program.cr
50+
.Ed
51+
52+
Make sure to always use --release for production-ready executables and when performing benchmarks.
53+
54+
The optimizations are not turned on by default because the compile times are much faster without them and the performance of the program is still pretty good without them, so it allows to use the crystal command almost to be used as if it was an interpreter.
55+
56+
.Bl -tag -width "12345678" -compact
57+
.Pp
58+
.Sh OPTIONS
59+
The crystal command accepts the following options
60+
61+
.Bl -tag -width "12345678" -compact
62+
.Pp
63+
.It
64+
.Cm init
65+
TYPE
66+
NAME
67+
.Op DIR
68+
.Pp
69+
Generate a new project.
70+
.Pp
71+
TYPE is one of:
72+
.Bl -tag -width "12345678" -compact
73+
.Pp
74+
.It Sy lib
75+
Creates a library skeleton
76+
.It Sy app
77+
Creates an application skeleton
78+
.El
79+
80+
This initializes the lib/app project folder as a git repository, with a license file, a readme file, a .travis.yml file for Travis CI integration, a shard.yml for use with shards (the Crystal dependency manager), a .gitignore file, and src and spec folders.
81+
.Bd -literal -offset
82+
NAME - name of project to be generated, eg: example
83+
.Pp
84+
DIR - directory where project will be generated, default: NAME
85+
.Ed
86+
87+
.Pp
88+
.It
89+
.Cm build
90+
.Op options
91+
programfile
92+
--
93+
.Op arguments
94+
.Pp
95+
Compile program.
96+
.Pp
97+
Options:
98+
.Bl -tag -width "12345678" -compact
99+
.Pp
100+
.It Fl -cross-compile
101+
Generate an object file for cross compilation and prints the command to build the executable.
102+
The object file should be copied to the target system and the printed command should be executed there. This flag mainly exists for porting the compiler to new platforms, where possible run the compiler on the target platform directly.
103+
.It Fl -d, Fl -debug
104+
Generate the output with symbolic debug symbols.
105+
These are read when debugging the built program with tools like lldb, gdb, valgrind etc. and provide mappings to the original source code for those tools.
106+
.It Fl D Ar FLAG, Fl -define Ar FLAG
107+
Define a compile-time flag. This is useful to conditionally define types, methods, or commands based on flags available at compile time. The default flags are from the target triple given with --target-triple or the hosts default, if none is given.
108+
.It Fl -emit Op asm|llvm-bc|llvm-ir|obj
109+
Comma separated list of types of output for the compiler to emit. You can use this to see the generated LLVM IR, LLVM bitcode, assembly, and object files.
110+
.It Fl f Ar text|json, Fl -format Ar text|json
111+
Format of output. Defaults to text. The json format can be used to get a more parser-friendly output.
112+
.It Fl -ll
113+
Dump LLVM assembly file to output directory.
114+
.It Fl -link-flags FLAGS
115+
Pass additional flags to the linker. Though you can specify those flags on the source code, this is useful for passing environment specific information directly to the linker, like non-standard library paths or names. For more information on specifying linker flags on source, you can read the "C bindings" section of the documentation available on the official web site.
116+
.It Fl -mcpu CPU
117+
Specify the name of the processor. This will pass a -mcpu flag to LLVM, and is only intended to be used for cross-compilation.
118+
.It Fl -no-color
119+
Disable colored output.
120+
.It Fl -no-codegen
121+
Don't do code generation, just parse the file.
122+
.It Fl o
123+
Specify filename of output.
124+
.It Fl -prelude
125+
Specify prelude to use. The default one initializes the garbage collector. You can also use --prelude=empty to use no preludes. This can be useful for checking code generation for a specific source code file.
126+
.It Fl -release
127+
Turn on optimizations for the generated code, which are disabled by default.
128+
.It Fl -error-trace
129+
Show full stack trace. Disabled by default, as the full trace usually makes error messages less readable and not always deliver relevant information.
130+
.It Fl s, -stats
131+
Print runtime statistics about the different compiler stages for the current build. Output time and used memory for each compiler process.
132+
.It Fl -single-module
133+
Generate a single LLVM module.
134+
.It Fl -threads
135+
Maximum number of threads to use for code generation. The default is 8 threads.
136+
.It Fl -target Ar TRIPLE
137+
Enable target triple; intended to use for cross-compilation. See llvm documentation for more information about target triple.
138+
.It Fl -verbose
139+
Display the commands executed by the system.
140+
.El
141+
142+
.Pp
143+
.It
144+
.Cm deps
145+
.Op options
146+
.Ar <command>
147+
.Pp
148+
Alias for shards, the dependency manager for Crystal language.
149+
.Pp
150+
.It
151+
.Cm docs
152+
.Pp
153+
Generate documentation from comments using a subset of markdown. The output is saved in html format on the created doc/ folder. More information about documentation conventions can be found at https://crystal-lang.org/docs/conventions/documenting_code.html.
154+
.Pp
155+
.It Cm eval
156+
.Pp
157+
Evaluate code from arguments or, if no arguments are passed, from the standard input. Useful for experiments.
158+
It accepts the flags --stats, --release, and --help, as the build command does.
159+
.Pp
160+
.It
161+
.Cm play
162+
.Op options
163+
.Pp
164+
Starts the crystal playground server on port 8080, by default.
165+
.Pp
166+
Options:
167+
.Bl -tag -width "12345678" -compact
168+
.Pp
169+
.It Fl p Fl -port
170+
Run the playground on the specified port. Default is 8080.
171+
.It Fl b Ar HOST Fl -binding Ar HOST
172+
Bind the playground to the specified IP.
173+
.It Fl v Fl -verbose
174+
Display detailed information of the executed code.
175+
.It Fl h Fl -help
176+
Show a help message about play command options.
177+
.El
178+
.Pp
179+
.It
180+
.Cm run
181+
.Op options
182+
programfile
183+
--
184+
.Op arguments
185+
.Pp
186+
The default command. Compile and run program.
187+
.Pp
188+
Options:
189+
Same as the build options.
190+
.Pp
191+
.It
192+
.Cm spec
193+
.Pp
194+
Compile and run specs (in spec directory).
195+
.Pp
196+
.It
197+
.Cm tool
198+
.Op tool
199+
.Op switches
200+
programfile
201+
--
202+
.Op arguments
203+
.Pp
204+
Run a tool. The available tools are: context, format, hierarchy, implementations, and types.
205+
.Pp
206+
Tools:
207+
.Bl -tag -offset indent
208+
.It Cm context
209+
Show context for given location.
210+
.It Cm format
211+
Format project, directories and/or files with the coding style used in the standard library. You can use the
212+
.Fl -check
213+
flag to check whether the formatter would make any changes.
214+
.It Cm hierarchy
215+
Show hierarchy of types from file. Also show class and struct members, with type and size. Types can be filtered with a regex by using the
216+
.Fl e
217+
flag.
218+
.It Cm implementations
219+
Show implementations for a given call. Use
220+
.Fl -cursor
221+
to specify the cursor position. The format for the cursor position is file:line:column.
222+
.It Cm types
223+
Show type of main variables of file.
224+
.El
225+
.Pp
226+
.It Cm version, Fl -version, v
227+
.Pp
228+
Show version.
229+
.El
230+
.Sh SEE ALSO
231+
.Fn shards 1
232+
.Bl -hang -compact -width "https://github.com/crystal-lang/crystal/1234"
233+
.It https://crystal-lang.org/
234+
The official web site.
235+
.It https://github.com/crystal-lang/crystal
236+
Official Repository.
237+
.El

0 commit comments

Comments
 (0)
Please sign in to comment.