Skip to content

Commit

Permalink
add a basic config with parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Apr 25, 2024
1 parent 276726b commit 7f79f3d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
5 changes: 5 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
projects:
- name: "project-1"
type: "git"
location: "local" # local or remote
path: "/path/to/project-1" # local path or remote url
10 changes: 9 additions & 1 deletion src/cli.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ require "option_parser"
require "log"
require "emoji"
require "colorize"
require "./models/config"
require "./runway"

module Runway
module Cli
def self.run
opts = self.opts

log = self.logger(opts[:log_level])
log.info { Emoji.emojize(":airplane: runway starting") }
log.info { Emoji.emojize(":book: loading runway configuration") }

log.debug { "attempting to load config from #{opts[:config_path]}"}
config = RunwayConfiguration.from_yaml(File.open(opts[:config_path]))
log.info { Emoji.emojize(":white_check_mark: loaded configuration successfully") }

Runway.start(log, config)
end

# Parse command line options
Expand Down
Empty file removed src/lib/config.cr
Empty file.
15 changes: 15 additions & 0 deletions src/models/config.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require "yaml"

# https://crystal-lang.org/api/1.12.1/YAML/Serializable.html
class RunwayConfiguration
include YAML::Serializable
property projects : Array(Project)
end

class Project
include YAML::Serializable
property name : String
property type : String
property location : String
property path : String
end
9 changes: 6 additions & 3 deletions src/runway.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
require "./cli"

CLI.run
module Runway
def self.start(log, config)
log.info { Emoji.emojize(":airplane: starting runway") }
log.info { "#{config. projects.size} #{config.projects.size == 1 ? "project" : "projects"} loaded" }
end
end

0 comments on commit 7f79f3d

Please sign in to comment.