Developer's Diary
Software development, with Terry Ebdon
03-Jun-2020 Convention & configuration

Simplification

Weekly vs daily configuration

A project will be either be page-per-day or week-per-day. In WebDoxy version 1.0.0 the --journal option adds new pages to the project. I've been assuming that weekly pages would be added via a new --week option. That seems redundant. If it's a weekly project then it has to have weekly pages, there should be no need for a specific option.

e.g. The following command should be sufficient to add today's page to the MyDaily project and this week's page to the MyWeekly project:

groovy WebDoxy.groovy --journal MyDaily MyWeekly

Yesterday I suggested using project-specific config.groovy files. WebDoxy can use these to determine the project type:

project {
journal {
type = 'weekly' // No need for --week
folders {
annually = true
monthly = true
daily = false
}
}
}

Config sequencing

WebDoxy executes actions against one or more projects mentioned in the command arguments. If no projects are specified then the actions are performed on the default project list.

if ( options.project ) {
projects = [ options.project ]
} else {
projects = options.arguments() ?: buildConfig.defaultProjects
}

This code accesses the project configuration in WebDoxy's constructor. i.e. before my proposed new logic, for project-specific configs, would happen. This will either have to be moved or a default configuration loaded that's replaced as needed. The latter option sounds too complex, but it may make sense when several projects are specified and not all have their own configuration. I'd use this approach if backward compatibility was a significant issue. That doesn't apply here, so the simpler approach is better. I'll remove the default project list, and force a failure if no projects are specified for any command other than --help.

Note
The --project option is used by the --stub command. This generates a list of stub pages and adds them to a project. It's an odd feature as it's the only command that assumes "left over" arguments are page names, instead of project names. The 'if' statement, in the above fragment, allows other commands to use --project but WebDoxy is never used that way. Also the stubs() method allows for multiple projects which the command line validation explicitly disallows.

02-JUN-2020 👈 Top of page 👉 10-JUN-2020

© 2020 Terry Ebdon.

Find me coding on GitHub, networking on LinkedIn, answering questions on Stack Exchange and hanging out on twitter.