Skip to content

Commit

Permalink
feat(commands): add config setup force flag for override
Browse files Browse the repository at this point in the history
  • Loading branch information
devnote-dev committed Aug 5, 2024
1 parent a14e97d commit c52d42e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/commands/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ module Geode::Commands
def setup : Nil
@name = "setup"
@summary = "setup the geode config"

add_option "force", description: "force override the existing config"
end

def run(arguments : Cling::Arguments, options : Cling::Options) : Nil
Expand All @@ -99,10 +101,15 @@ module Geode::Commands
Dir.mkdir_p Geode::Config::LIBRARY_DIR
end

begin
Geode::Config.path
rescue
if options.has? "force"
Geode::Config.new.save
else
begin
Geode::Config.path
warn "A config already exists", "Rerun with the '--force' flag to override"
rescue
Geode::Config.new.save
end
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/config.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Geode
class Config
include YAML::Serializable

CACHE_DIR = {% if flag?(:win32) %}
Path[ENV["LOCALAPPDATA"], "geode"]
{% else %}
Expand Down Expand Up @@ -53,8 +55,6 @@ module Geode
end
end

include YAML::Serializable

getter notices : Notices
getter presets : Presets

Expand Down

0 comments on commit c52d42e

Please sign in to comment.