Skip to content

Commit

Permalink
Improved readme to new encloseWithMermaidBackticks feature; fixed bac…
Browse files Browse the repository at this point in the history
…ksticks suffix
  • Loading branch information
KarnerTh committed Mar 17, 2022
1 parent 1d7d65b commit c6aff4f
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 668 deletions.
1 change: 1 addition & 0 deletions .mermerd.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
showAllConstraints: true
encloseWithMermaidBackticks: false
outputFileName: "my-db.mmd"

# These connection strings are available as suggestions in the cli (use tab to access)
Expand Down
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ func init() {
rootCmd.Flags().StringVar(&runConfig, "runConfig", "", "run configuration (replaces global configuration)")
rootCmd.Flags().Bool(config.ShowAllConstraintsKey, false, "show all constraints, even though the table of the resulting constraint was not selected")
rootCmd.Flags().Bool(config.UseAllTablesKey, false, "use all available tables")
rootCmd.Flags().BoolP(config.EncloseWithMermaidBackticksKey, "e", false, "enclose output with mermaid backticks (needed for e.g. in markdown viewer)")
rootCmd.Flags().StringP(config.ConnectionStringKey, "c", "", "connection string that should be used")
rootCmd.Flags().StringP(config.SchemaKey, "s", "", "schema that should be used")
rootCmd.Flags().StringP(config.OutputFileNameKey, "o", "result.mmd", "output file name")

bindFlagToViper(config.ShowAllConstraintsKey)
bindFlagToViper(config.UseAllTablesKey)
bindFlagToViper(config.EncloseWithMermaidBackticksKey)
bindFlagToViper(config.ConnectionStringKey)
bindFlagToViper(config.SchemaKey)
bindFlagToViper(config.OutputFileNameKey)
Expand Down
9 changes: 4 additions & 5 deletions diagram/diagram.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ func Create(result *database.Result) error {
return err
}

if config.EncloseWithMermaidBackticks() {
_, err = buffer.WriteString("\n```")
}

_, err = buffer.WriteString("\n\n")

}

constraints := strings.Builder{}
Expand All @@ -77,6 +72,10 @@ func Create(result *database.Result) error {
return err
}

if config.EncloseWithMermaidBackticks() {
_, err = buffer.WriteString("```\n")
}

if err := buffer.Flush(); err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions exampleRunConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ selectedTables:
# Additional flags
showAllConstraints: true
outputFileName: "my-db.mmd"
encloseWithMermaidBackticks: false
24 changes: 24 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,32 @@ require (
)

require (
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.11.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.2.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/pgtype v1.10.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 // indirect
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading

0 comments on commit c6aff4f

Please sign in to comment.