cli improvements, added examples to nightly package

This commit is contained in:
Anton-4 2021-11-09 17:25:18 +01:00
parent 2a45798cba
commit 46a09d81e8
3 changed files with 19 additions and 8 deletions

View file

@ -108,12 +108,14 @@ test-all:
build-nightly-release: build-nightly-release:
FROM +test-rust FROM +test-rust
COPY --dir .git ./ COPY --dir .git LICENSE LEGAL_DETAILS ./
# version.txt is used by the CLI: roc --version # version.txt is used by the CLI: roc --version
RUN printf "nightly pre-release, built from commit " > version.txt RUN printf "nightly pre-release, built from commit " > version.txt
RUN git log --pretty=format:'%h' -n 1 >> version.txt RUN git log --pretty=format:'%h' -n 1 >> version.txt
RUN printf " on: " >> version.txt
RUN date >> version.txt
RUN cargo build --features with_sound --release RUN cargo build --features with_sound --release
RUN cd ./target/release && tar -czvf roc_linux_x86_64.tar.gz ./roc RUN cd ./target/release && tar -czvf roc_linux_x86_64.tar.gz ./roc ../../LICENSE ../../LEGAL_DETAILS ../../examples/hello-world ../../examples/hello-rust ../../examples/hello-zig ../../compiler/builtins/bitcode/src/ ../../roc_std
SAVE ARTIFACT ./target/release/roc_linux_x86_64.tar.gz AS LOCAL roc_linux_x86_64.tar.gz SAVE ARTIFACT ./target/release/roc_linux_x86_64.tar.gz AS LOCAL roc_linux_x86_64.tar.gz
# compile everything needed for benchmarks and output a self-contained dir from which benchmarks can be run. # compile everything needed for benchmarks and output a self-contained dir from which benchmarks can be run.

View file

@ -23,6 +23,7 @@ pub const CMD_REPL: &str = "repl";
pub const CMD_EDIT: &str = "edit"; pub const CMD_EDIT: &str = "edit";
pub const CMD_DOCS: &str = "docs"; pub const CMD_DOCS: &str = "docs";
pub const CMD_CHECK: &str = "check"; pub const CMD_CHECK: &str = "check";
pub const CMD_VERSION: &str = "version";
pub const FLAG_DEBUG: &str = "debug"; pub const FLAG_DEBUG: &str = "debug";
pub const FLAG_DEV: &str = "dev"; pub const FLAG_DEV: &str = "dev";
@ -103,8 +104,11 @@ pub fn build_app<'a>() -> App<'a> {
.subcommand(App::new(CMD_REPL) .subcommand(App::new(CMD_REPL)
.about("Launch the interactive Read Eval Print Loop (REPL)") .about("Launch the interactive Read Eval Print Loop (REPL)")
) )
.subcommand(App::new(CMD_VERSION)
.about("Print version information")
)
.subcommand(App::new(CMD_CHECK) .subcommand(App::new(CMD_CHECK)
.about("Build a binary from the given .roc file, but don't run it") .about("When developing, it's recommended to run `check` before `build`. It may provide a useful error message in cases where `build` panics")
.arg( .arg(
Arg::new(FLAG_TIME) Arg::new(FLAG_TIME)
.long(FLAG_TIME) .long(FLAG_TIME)
@ -190,7 +194,7 @@ pub fn build_app<'a>() -> App<'a> {
if cfg!(feature = "editor") { if cfg!(feature = "editor") {
app.subcommand( app.subcommand(
App::new(CMD_EDIT).about("Launch the Roc editor").arg( App::new(CMD_EDIT).about("Launch the Roc editor (Work In Progress)").arg(
Arg::new(DIRECTORY_OR_FILES) Arg::new(DIRECTORY_OR_FILES)
.index(1) .index(1)
.multiple_values(true) .multiple_values(true)

View file

@ -1,13 +1,13 @@
use roc_cli::build::check_file; use roc_cli::build::check_file;
use roc_cli::{ use roc_cli::{BuildConfig, CMD_BUILD, CMD_CHECK, CMD_DOCS, CMD_EDIT, CMD_REPL, CMD_VERSION, DIRECTORY_OR_FILES, FLAG_TIME, ROC_FILE, build_app, docs, repl};
build_app, docs, repl, BuildConfig, CMD_BUILD, CMD_CHECK, CMD_DOCS, CMD_EDIT, CMD_REPL,
DIRECTORY_OR_FILES, FLAG_TIME, ROC_FILE,
};
use roc_load::file::LoadingProblem; use roc_load::file::LoadingProblem;
use std::fs::{self, FileType}; use std::fs::{self, FileType};
use std::io; use std::io;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
#[macro_use]
extern crate const_format;
#[global_allocator] #[global_allocator]
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
@ -122,6 +122,11 @@ fn main() -> io::Result<()> {
Ok(0) Ok(0)
} }
Some(CMD_VERSION) => {
println!("roc {}", concatcp!(include_str!("../../version.txt"), "\n"));
Ok(0)
}
_ => unreachable!(), _ => unreachable!(),
}?; }?;