WIP: feature/45-improve-tooling #46
4 changed files with 41 additions and 4 deletions
|
@ -4,6 +4,10 @@ shards:
|
||||||
git: https://github.com/crystal-ameba/ameba.git
|
git: https://github.com/crystal-ameba/ameba.git
|
||||||
version: 1.6.1
|
version: 1.6.1
|
||||||
|
|
||||||
|
baked_file_system:
|
||||||
|
git: https://github.com/schovi/baked_file_system.git
|
||||||
|
version: 0.10.0
|
||||||
|
|
||||||
crinja:
|
crinja:
|
||||||
git: https://github.com/straight-shoota/crinja.git
|
git: https://github.com/straight-shoota/crinja.git
|
||||||
version: 0.8.1
|
version: 0.8.1
|
||||||
|
|
|
@ -26,6 +26,9 @@ dependencies:
|
||||||
github: hugopl/version_from_shard
|
github: hugopl/version_from_shard
|
||||||
tablo:
|
tablo:
|
||||||
github: hutou/tablo
|
github: hutou/tablo
|
||||||
|
baked_file_system:
|
||||||
|
github: schovi/baked_file_system
|
||||||
|
version: 0.10.0
|
||||||
|
|
||||||
development_dependencies:
|
development_dependencies:
|
||||||
ameba:
|
ameba:
|
||||||
|
|
|
@ -1,14 +1,36 @@
|
||||||
require "./abstract_command"
|
require "./abstract_command"
|
||||||
|
require "../file_storage"
|
||||||
|
|
||||||
module GX::Commands
|
module GX::Commands
|
||||||
class ConfigInit < AbstractCommand
|
class ConfigInit < AbstractCommand
|
||||||
def initialize(config : GX::Config) # FIXME
|
def initialize(@config : GX::Config)
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
puts "FIXME: detect if config is present"
|
config_dir = File.join(@config.home_dir, ".config", "mfm")
|
||||||
puts "FIXME: compute config path (either default, or from command line)"
|
config_file_path = File.join(config_dir, "config.yml")
|
||||||
puts "FIXME: create config file from default if needed"
|
|
||||||
|
# Guard condition to exit if the configuration file already exists
|
||||||
|
if File.exists?(config_file_path)
|
||||||
|
puts "Configuration file already exists at #{config_file_path}. No action taken."
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
puts "Creating initial configuration file at #{config_file_path}"
|
||||||
|
|
||||||
|
# Ensure the configuration directory exists
|
||||||
|
FileUtils.mkdir_p(config_dir)
|
||||||
|
|
||||||
|
# Read the default configuration content from the baked file storage
|
||||||
|
default_config_content = FileStorage.get("sample.mfm.yaml")
|
||||||
|
|
||||||
|
# Write the default configuration to the target path
|
||||||
|
File.write(config_file_path, default_config_content)
|
||||||
|
|
||||||
|
puts "Configuration file created successfully."
|
||||||
|
rescue ex
|
||||||
|
STDERR.puts "Error creating the configuration file: #{ex.message}"
|
||||||
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.handles_mode
|
def self.handles_mode
|
||||||
|
|
8
src/file_storage.cr
Normal file
8
src/file_storage.cr
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
require "baked_file_system"
|
||||||
|
|
||||||
|
class FileStorage
|
||||||
|
extend BakedFileSystem
|
||||||
|
|
||||||
|
bake_folder "../static"
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue