Merge pull request 'CLI use readline' (#5) from cli-use-readline into main

This commit is contained in:
Dominic Grimm 2022-01-10 17:42:26 +00:00
commit dea9211108
5 changed files with 35 additions and 22 deletions

View file

@ -9,8 +9,7 @@ WORKDIR /app
COPY --from=micrate-deps /app/shard.yml /app/shard.lock ./
COPY --from=micrate-deps /app/lib lib/
COPY ./micrate/src ./src
COPY ./scripts ./scripts
RUN . ./scripts/build.sh ${BUILD_ENV}
RUN shards build --production --static --release --no-debug --verbose -s -p -t
FROM crystallang/crystal:latest-alpine as deps
WORKDIR /app
@ -24,9 +23,11 @@ WORKDIR /app
COPY --from=deps /app/shard.yml /app/shard.lock ./
COPY --from=deps /app/lib ./lib
COPY ./src ./src
COPY ./scripts ./scripts
RUN . ./scripts/build.sh ${BUILD_ENV}
RUN if [ "${BUILD_ENV}" = "development" ]; then \
shards build --static --verbose -s -p -t; \
else \
shards build --static --release --no-debug --verbose -s -p -t; \
fi
FROM scratch as runner
WORKDIR /
COPY --from=micrate-builder /app/bin/micrate ./bin/micrate

View file

@ -1,14 +0,0 @@
#!/usr/bin/env sh
BASE_FLAGS="--production --static --verbose -s -p -t"
DEV_FLAGS="$BASE_FLAGS"
PROD_FLAGS="--release --no-debug $BASE_FLAGS"
echo "Building targets in '$1' mode..."
if [ "$1" = "development" ]; then
# shellcheck disable=SC2086
time shards build $DEV_FLAGS
else
# shellcheck disable=SC2086
time shards build $PROD_FLAGS
fi

View file

@ -20,10 +20,22 @@ shards:
git: https://github.com/axentro/crystal-argon2.git
version: 0.1.3
cute:
git: https://github.com/papierkorb/cute.git
version: 0.4.0
db:
git: https://github.com/crystal-lang/crystal-db.git
version: 0.10.1
fancyline:
git: https://github.com/papierkorb/fancyline.git
version: 0.4.1
future:
git: https://github.com/crystal-community/future.cr.git
version: 1.0.0
granite:
git: https://github.com/amberframework/granite.git
version: 0.23.0

View file

@ -34,3 +34,5 @@ dependencies:
github: mrrooijen/commander
compiled_license:
github: grimmigerFuchs/compiled_license
fancyline:
github: Papierkorb/fancyline

View file

@ -1,15 +1,27 @@
require "commander"
require "compiled_license"
require "fancyline"
require "./db"
module MW
module Cli
module CLI
extend self
private FANCY = Fancyline.new
FANCY.actions.set Fancyline::Key::Control::CtrlC do
exit
end
private def input(prompt : String) : String
print prompt
(gets || "").chomp.strip
x = FANCY.readline(prompt)
if x
x.chomp.strip
else
""
end
end
cli = Commander::Command.new do |cmd|