From 65ea7c412eea275d999f8005f6e8c58687ff5b14 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Tue, 19 Jul 2016 18:09:52 -0400 Subject: create data subdirs on init --- src/guff/cli.cr | 11 +++++++++++ 1 file changed, 11 insertions(+) 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) -- cgit v1.2.3