nuke old and bad config stuff

This reverts commit 52f3a086f2.
It also manually bandages over the places where it was ripped out.

it was never a good idea in the first place
This commit is contained in:
garret 2022-06-17 22:45:44 +01:00
parent a86e96d96b
commit d636f1b008
4 changed files with 8 additions and 117 deletions

View File

@ -5,24 +5,16 @@ script_version = "2.1.0"
script_namespace = "garret.chapters"
local haveDepCtrl, DependencyControl, depctrl = pcall(require, "l0.DependencyControl")
local simpleconf, config_dir
if haveDepCtrl then
depctrl = DependencyControl {
--feed="TODO",
{
{"garret.simpleconf", url="https://github.com/garret1317/aegisub-scripts",}
--feed="TODO"},
}
}
simpleconf = depctrl:requireModules()
config_dir = depctrl.configDir
else
simpleconf = require 'garret.simpleconf'
config_dir = "?user/config"
end
local config = simpleconf.get_config(aegisub.decode_path(config_dir.."/"..script_namespace..".conf"), {language = "eng", language_ietf = "en"})
--local config = simpleconf.get_config(aegisub.decode_path(config_dir.."/"..script_namespace..".conf"), {language = "eng", language_ietf = "en"})
local config = {language = "eng", language_ietf = "en"}
function ms_to_human(start) -- From Significance
local timecode=math.floor(start/1000)
@ -62,7 +54,6 @@ function get_user_path(default_dir)
end
function main(sub)
aegisub.log(config_dir)
local times = {}
local names = {}
for i=1,#sub do

View File

@ -5,22 +5,19 @@ script_version = "2.1.0"
script_namespace = "garret.restyler"
local haveDepCtrl, DependencyControl, depctrl = pcall(require, "l0.DependencyControl")
local simpleconf
local karaskel, cleantags
if haveDepCtrl then
depctrl = DependencyControl {
--feed="TODO",
{"karaskel", "cleantags", {"garret.simpleconf", url="https://github.com/garret1317/aegisub-scripts"}, }
{"karaskel", "cleantags"}
}
kara, clean, simpleconf = depctrl:requireModules()
config_dir = depctrl.configDir
kara, clean = depctrl:requireModules()
else
include("karaskel.lua")
include("cleantags.lua")
simpleconf = require 'garret.simpleconf'
config_dir = "?user/config"
end
local config = simpleconf.get_config(aegisub.decode_path(config_dir.."/"..script_namespace..".conf"), {new_style = "Default"})
-- local config = simpleconf.get_config(aegisub.decode_path(config_dir.."/"..script_namespace..".conf"), {new_style = "Default"})
-- TODO: detect pre-existing inline tags
-- probably need some kind of ass parsing, or a hack with match()
@ -52,7 +49,7 @@ end
function main(sub, sel)
local _, styles = karaskel.collect_head(sub, false)
--local config.new_style = "Default" -- the one we'll be changing stuff to - TODO: configurable
local config.new_style = "Default"
local new_style = styles[config.new_style]
for h, i in ipairs(sel) do
-- TODO: automatically exclude styles (also configurable)

View File

@ -1,51 +0,0 @@
---
title: simpleconf.lua's Fine Manual
lang: en-GB
...
# simpleconf.lua's Fine Manual
read it
## Usage
### Loading config files
Synopsis: `config = simpleconf.get_config([config_file, defaults])`
`@config_file` (`string`)
Path of the file to load.
`@defaults` (`table`)
A table containing your default settings.
`config` (table)
Contains config values.
Both values are optional.
If the file and the defaults are present, it loads the defaults, then overwrites their values with those of the file.
If the file is present, but not the defaults, it just loads the contents of the file.
If the file isn't present, but the defaults are, it just loads the defaults, and you're using it wrong.
If nothing is present, it returns an empty table.
| File | Defaults | Result |
| ---- | -------- | ------ |
| 1 | 1 | file overwrites defaults |
| 1 | 0 | just the file |
| 0 | 1 | just the defaults |
| 0 | 0 | nothing |
## Config file format
```
bool = true
number = 123
string = the quick brown fox jumps over the lazy dog
I am a comment!
```
(don't tell anyone, but it's all just a pattern nicked from Programming in Lua (page 82, 4th edition))

View File

@ -1,46 +0,0 @@
-- primitive config handler
local function tobool(value)
if value == "true" then
return true
elseif value == "false" then
return false
else
return nil
end
end
local function cast(value)
return tonumber(value) or tobool(value) or value
end
local function get_config(config_file, defaults)
local conf = defaults or {}
local ok, lines = pcall(io.lines, config_file)
if ok then
for line in lines do
local key, value = string.match(line, "(%a+)%s*=%s*(.+)")
conf[key] = cast(value)
end
end
return conf
end
local simpleconf = {get_config = get_config}
local have_depctrl, depctrl = pcall(require, "l0.DependencyControl")
if have_depctrl then
local version = depctrl{
name = "Simple (bad) Config",
version = "0.1.0",
description = "primitive config handler",
author = "garret",
url = "http://github.com/garret1317/aegisub-scripts",
moduleName = "garret.simpleconf"}
simpleconf.version = version
return version:register(simpleconf)
else
return simpleconf
end