1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
mod asm;
mod run;
use switchboard::{Switchboard, SwitchQuery};
fn main() {
let mut args = Switchboard::from_env();
if args.named("help").short('h').as_bool() {
print_help();
}
if args.named("version").as_bool() {
print_version();
}
if args.named("verbose").short('v').as_bool() {
log::set_log_level(log::LogLevel::Info);
}
match args.peek() {
Some("run") => { args.pop(); run::main(args) },
Some("asm") => { args.pop(); asm::main(args) },
_ => run::main(args),
}
}
fn print_help() -> ! {
println!("\
Usage: br [source]
br asm [source] [destination] [extension]
Integrated Bedrock assembler and emulator.
Usage:
To load a Bedrock program from a file, run `br <path>`, where
<path> is the path to an assembled Bedrock program.
To load a Bedrock program from piped input, run `<command> | br`,
where <command> is a command that generates Bedrock bytecode.
To assemble a Bedrock program from a source file and write to an
output file, run `br asm <source> <output>`, where <source> is the
path of the source file and <output> is the path to write to.
To assemble and run a Bedrock program without saving to a file,
run `br asm <source> | br`, where <source> is the path of the
source file.
Environment variables:
BEDROCK_PATH
A list of colon-separated paths which will be searched to find
a Bedrock program when the program doesn't exist in the current
directory. This allows the user to run frequently-used programs
from any directory.
BEDROCK_LIBS
A list of colon-separated paths which will be searched to find
Bedrock source code files to use as libraries when assembling a
Bedrock program. If a library file resolves an unresolved symbol
in the program being assembled, the library file will be merged
into the program.
Arguments:
[program] Path to a Bedrock program to run
Switches:
--verbose, (-v) Print additional debug information
--version Print the assembler version and exit
--help (-h) Prints help
--debug, (-d) Show debug information while the program is running
--fullscreen (-f) Start the program in fullscreen mode (toggle with F11)
--size=<dim> (-s) Set the initial window size in the format <width>x<height>
--zoom=<scale> (-z) Set the pixel size for the screen (change with F5/F6)
--palette=<pal> Set a debug colour palette in the format <rgb>,... (toggle with F2)
--show-cursor (-c) Show the operating system cursor over the window
--decode-stdin (-i) Decode standard input
--encode-stdout (-o) Encode standard output
Arguments (asm mode):
[source] Bedrock source code file to assemble.
[destination] Destination path for assembler output.
[extension] File extension to identify source files.
Switches (asm mode):
--no-libs Don't include libraries or resolve references.
--no-project-libs Don't include project libraries
--no-env-libs Don't include environment libraries.
--tree Show the resolved source file heirarchy
--check Assemble the program without saving any output
--resolve Only return resolved source code.
--symbols Generate debug symbols with file extension '.br.sym'
");
std::process::exit(0);
}
fn print_version() -> ! {
let name = env!("CARGO_PKG_NAME");
let version = env!("CARGO_PKG_VERSION");
eprintln!("{name} v{version}");
eprintln!("Written by Ben Bridle.");
std::process::exit(0);
}
|