summaryrefslogtreecommitdiffstats
path: root/dev/sentry_cli.cr
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2017-12-30 15:18:59 -0600
committerOmar Roth <omarroth@hotmail.com>2017-12-30 15:18:59 -0600
commitc7c8cc1e857c83db81dc0dfe4784dc59c08074fe (patch)
treea0713ee3d6742687e2609a74f0bf8da1ed263a3d /dev/sentry_cli.cr
parent764fdf42ef6baa83a366490b770212e95da65e0a (diff)
downloadinvidious-c7c8cc1e857c83db81dc0dfe4784dc59c08074fe.tar.gz
invidious-c7c8cc1e857c83db81dc0dfe4784dc59c08074fe.tar.bz2
invidious-c7c8cc1e857c83db81dc0dfe4784dc59c08074fe.zip
Add sentry (from updated fork)
Diffstat (limited to 'dev/sentry_cli.cr')
-rw-r--r--dev/sentry_cli.cr99
1 files changed, 99 insertions, 0 deletions
diff --git a/dev/sentry_cli.cr b/dev/sentry_cli.cr
new file mode 100644
index 00000000..6e3f4530
--- /dev/null
+++ b/dev/sentry_cli.cr
@@ -0,0 +1,99 @@
+require "option_parser"
+require "yaml"
+require "./sentry"
+
+process_name = nil
+
+begin
+ shard_yml = YAML.parse File.read("shard.yml")
+ name = shard_yml["name"]?
+ process_name = name.as_s if name
+rescue e
+end
+
+build_args = [] of String
+build_command = "crystal build ./src/#{process_name}.cr"
+run_args = [] of String
+run_command = "./#{process_name}"
+files = ["./src/**/*.cr", "./src/**/*.ecr"]
+files_cleared = false
+show_help = false
+should_build = true
+
+OptionParser.parse! do |parser|
+ parser.banner = "Usage: ./sentry [options]"
+ parser.on(
+ "-n NAME",
+ "--name=NAME",
+ "Sets the name of the app process (current name: #{process_name})") { |name| process_name = name }
+ parser.on(
+ "-b COMMAND",
+ "--build=COMMAND",
+ "Overrides the default build command") { |command| build_command = command }
+ parser.on(
+ "--build-args=ARGS",
+ "Specifies arguments for the build command") do |args|
+ args_arr = args.strip.split(" ")
+ build_args = args_arr if args_arr.size > 0
+ end
+ parser.on(
+ "--no-build",
+ "Skips the build step") { should_build = false }
+ parser.on(
+ "-r COMMAND",
+ "--run=COMMAND",
+ "Overrides the default run command") { |command| run_command = command }
+ parser.on(
+ "--run-args=ARGS",
+ "Specifies arguments for the run command") do |args|
+ args_arr = args.strip.split(" ")
+ run_args = args_arr if args_arr.size > 0
+ end
+ parser.on(
+ "-w FILE",
+ "--watch=FILE",
+ "Overrides default files and appends to list of watched files") do |file|
+ unless files_cleared
+ files.clear
+ files_cleared = true
+ end
+ files << file
+ end
+ parser.on(
+ "-i",
+ "--info",
+ "Shows the values for build/run commands, build/run args, and watched files") do
+ puts "
+ name: #{process_name}
+ build: #{build_command}
+ build args: #{build_args}
+ run: #{run_command}
+ run args: #{run_args}
+ files: #{files}
+ "
+ end
+ parser.on(
+ "-h",
+ "--help",
+ "Show this help") do
+ puts parser
+ exit 0
+ end
+end
+
+if process_name
+ process_runner = Sentry::ProcessRunner.new(
+ process_name: process_name.as(String),
+ build_command: build_command,
+ run_command: run_command,
+ build_args: build_args,
+ run_args: run_args,
+ should_build: should_build,
+ files: files
+ )
+
+ process_runner.run
+else
+ puts "🤖 Sentry error: 'name' not given and not found in shard.yml"
+ exit 1
+end