diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-07-19 18:09:52 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-07-19 18:09:52 -0400 |
commit | 65ea7c412eea275d999f8005f6e8c58687ff5b14 (patch) | |
tree | 84d47736a2c3e54ee0ba755d3b066b82ba3a365c | |
parent | 0b9227f43d4803ad183789f484006247573a3439 (diff) | |
download | guff-65ea7c412eea275d999f8005f6e8c58687ff5b14.tar.bz2 guff-65ea7c412eea275d999f8005f6e8c58687ff5b14.zip |
create data subdirs on init
-rw-r--r-- | src/guff/cli.cr | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/guff/cli.cr b/src/guff/cli.cr index 600f5d4..3752621 100644 --- a/src/guff/cli.cr +++ b/src/guff/cli.cr @@ -31,10 +31,21 @@ module Guff::CLI @data = Data.load(@config.system_dir) end + # list of subdirectories to create in data directory + DIRS = %w{files themes cache/themes} + def run + # create data dir STDERR.puts "Initializing data directory" Dir.mkdir(@config.data_dir) unless Dir.exists?(@config.data_dir) + # create data subdirs + DIRS.each do |dir| + abs_path = File.join(@config.data_dir, dir) + Dir.mkdir_p(abs_path) unless Dir.exists?(abs_path) + end + + # create database Guff::Database.new(@config.db_path) do |db| @data.init_sql.each do |sql| db.query(sql) |