diff --git a/Cargo.toml b/Cargo.toml index 21b50a0..3877e4d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,11 @@ name = "ucg" version = "0.0.1" authors = ["Jeremy Wall "] +description = "Runs a command on user specified triggers." +repository = "https://github.com/zaphar/ucg" +readme = "README.md" +keywords = ["compiler", "config"] +license = "Apache-2.0" [dependencies] nom = "^2.2" @@ -13,4 +18,4 @@ path = "src/lib.rs" [[bin]] name = "ucg" -path = "src/main.rs" \ No newline at end of file +path = "src/main.rs" diff --git a/README.md b/README.md new file mode 100644 index 0000000..8f059e9 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# Universal Configuration Generator. - A working title. + +This is an experiment in configuration management. The approach is not +to create a "parsable" config file format. We have plenty of +those. Instead we try to specify a grammar for describing +configuration values that can then target various configuration +formats to output to. + +In theory this could support anything from command line flags to json +to yaml or toml or even xml. + +The goal is to allow a global shared configuration repository that can +be version controlled, enforce some typesafety, and output +configuration for any application regardless of that applications +preferred format. + +## Examples + +Let statements introduce a new name in a ucg file. Most configurations +will be a tuple like below. Tuples are delimited by braces and have a list +of named fields in them. + + let mysql_conn_base = { + host = "db1.local.net", + port = 3306, // knows the difference between strings and numbers. + database = "place-holder", + }; + +You can use a previously defined tuple as the basis for a new tuple. Doing +this will make a copy of the source tuple and allow you to add new fields +or override an already existing field. + + let mysql_app_conn = mysql_conn_base{ + database = "appdb", + timeout = 30, + }; + +Types are inferred for tuple fields. We enforce type consistency when +overriding a field in a base tuple. The port field below expects a +number not a string so you will get a TypeFail error. + + + let bad_mysql_conn = mysql_conn_base{ + port = "3307", + } diff --git a/src/build.rs b/src/build.rs index 3be0cf5..818dc7c 100644 --- a/src/build.rs +++ b/src/build.rs @@ -1,3 +1,16 @@ +// Copyright 2017 Jeremy Wall +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. use parse::{parse, Statement, Expression, Value, FieldList, SelectorList}; use std::error::Error; diff --git a/src/lib.rs b/src/lib.rs index c25d98a..b44bd79 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,16 @@ +// Copyright 2017 Jeremy Wall +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #[macro_use] extern crate nom; diff --git a/src/main.rs b/src/main.rs index 117a0b9..7c9aaa4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,16 @@ +// Copyright 2017 Jeremy Wall +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. extern crate ucglib; fn main() { diff --git a/src/parse.rs b/src/parse.rs index 79d69da..7ee3273 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -1,3 +1,16 @@ +// Copyright 2017 Jeremy Wall +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. quick_error! { #[derive(Debug,PartialEq)] pub enum ParseError {