Skip to content

Commit

Permalink
doc: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
das6ng committed Nov 12, 2023
1 parent 7a7922a commit 04fae20
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 8 deletions.
78 changes: 71 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion bin/xlscfg/xlsxcfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added doc/example-sheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 04fae20

Please sign in to comment.