diff --git a/README.md b/README.md index 2c3f99b..d6e813f 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,81 @@ -# xlscfg +# xlsxcfg -config data from excel sheets +xlsxcfg load config data from excel sheets. -# Examples +## Installation + +*⚠Currently needs golang sdk* + +Run the following command: + +`go install github.com/dashengyeah/xlsxcfg/bin/xlsxcfg` + +## Config + +Default config file `xlsxcfg.yaml`: + +```yaml +# Protocol Buffer source config +proto: + # proto files need to parse. + files: ["example.proto"] + # proto message import paths. + import_path: ["."] +# xlsx sheet config +sheet: + # rows that is comment, will ignore + # in parsing + comment_rows: [1] + # row contains metadata + meta_row: 2 + # rows contain config data from this + data_row_start: 3 + # sheet name should add this suffix + # to find the proto message. + type_suffix: "Sheet" + # config data rows' list name in the + # sheet proto message. + list_field_name: "List" + # sheet name should add this suffix + # to find the data row proto message. + row_type_suffix: "SheetRow" +# output file config +output: + # output dir + dir: "." + # json + write_json: true + json_indent: " " + # proto bytes + write_bytes: true +``` + +## Examples 1. Basic + +- Protocol Buffer code: + ```protobuf +message PhoneNumber { + int64 Region = 1; + int64 No = 2; + string Ext = 3; +} + message MemberSheetRow { -    int32 ID = 1; -    string Name = 2; -    string Address = 3; + int32 ID = 1; + string Name = 2; + string Address = 3; + PhoneNumber Phone = 4; + repeated string Cities = 5; + repeated PhoneNumber PP = 6; } message MemberSheet { -    repeated MemberSheetRow List = 1; + repeated MemberSheetRow List = 1; } ``` + +- Excel sheet: + +![image](./doc/example-sheet.png) diff --git a/bin/xlscfg/xlsxcfg.yaml b/bin/xlscfg/xlsxcfg.yaml index d145691..fc4124e 100644 --- a/bin/xlscfg/xlsxcfg.yaml +++ b/bin/xlscfg/xlsxcfg.yaml @@ -5,7 +5,7 @@ proto: # proto message import paths. import_path: ["."] -# xls sheet config +# xlsx sheet config sheet: # rows that is comment, will ignore # in parsing diff --git a/doc/example-sheet.png b/doc/example-sheet.png new file mode 100644 index 0000000..392e276 Binary files /dev/null and b/doc/example-sheet.png differ