simplify readme and make a force flag for local overrides
This commit is contained in:
@@ -56,6 +56,7 @@ type Config struct {
|
||||
InputPath string
|
||||
OutputPath string
|
||||
AppendMode bool
|
||||
Force bool
|
||||
SingleFile bool
|
||||
MaxSize int64
|
||||
MaxDepth int
|
||||
@@ -79,6 +80,7 @@ func Parse() (*Config, error) {
|
||||
input string
|
||||
output string
|
||||
appendMd bool
|
||||
force bool
|
||||
maxSize int64
|
||||
maxDepth int
|
||||
ignores stringSlice
|
||||
@@ -91,6 +93,7 @@ func Parse() (*Config, error) {
|
||||
flag.StringVar(&input, "i", "", "single file input (append mode only)")
|
||||
flag.StringVar(&output, "o", "", "output markdown file path (required)")
|
||||
flag.BoolVar(&appendMd, "a", false, "append to existing output file")
|
||||
flag.BoolVar(&force, "f", false, "overwrite existing output file (non-append mode)")
|
||||
flag.Int64Var(&maxSize, "max-size", DefaultMaxSize, "max file size in bytes")
|
||||
flag.IntVar(&maxDepth, "max-depth", DefaultMaxDepth, "max directory recursion depth")
|
||||
flag.Var(&ignores, "ignore", "additional ignore patterns (glob, repeatable)")
|
||||
@@ -118,6 +121,7 @@ func Parse() (*Config, error) {
|
||||
cfg := &Config{
|
||||
OutputPath: output,
|
||||
AppendMode: appendMd,
|
||||
Force: force,
|
||||
MaxSize: maxSize,
|
||||
MaxDepth: maxDepth,
|
||||
Ignores: append(DefaultIgnores, ignores...),
|
||||
@@ -147,8 +151,8 @@ func Parse() (*Config, error) {
|
||||
cfg.AbsRoot = abs
|
||||
|
||||
if !appendMd {
|
||||
if _, err := os.Stat(output); err == nil {
|
||||
return nil, fmt.Errorf("output file %s already exists (use -a to append)", output)
|
||||
if _, err := os.Stat(output); err == nil && !force {
|
||||
return nil, fmt.Errorf("output file %s already exists (use -f to overwrite or -a to append)", output)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user