Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: change flag for section directory #12

Merged
merged 1 commit into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ Flags:
-l, --locale=STRING Specify the locale to pull. If not specified, the default locale will be used.
--raw It pulls raw data without converting it from HTML to Markdown.
-a, --save-article It pulls and saves the article in addition to the translation.
--without-section-dir It doesn't save in a directory named after the section ID.
--with-section-dir A .md file will be created in the section ID directory.
```

By default, the pull subcommand saves under `{contents_dir}/{section_id}`. You can also specify an option to output directly under `{contents_dir}/`.
By default, the pull subcommand saves under `{contents_dir}`. You can also specify an option to output directly under `{contents_dir}/{section_id}`.
If a Translation or Article already exists at the specified local path, it will be overwritten.

### empty
Expand All @@ -115,7 +115,7 @@ Flags:
-p, --permission-group-id=INT Specify the permission group ID. If not specified, the default value will be used.
-u, --user-segment-id=INT Specify the user segment ID. If not specified, the default value will be used.
--save-article It saves the article in addition to the translation.
--without-section-dir It doesn't save in a directory named after the section ID.
--with-section-dir A .md file will be created in the section ID directory.
```

The empty subcommand should not be used when adding a new Translation to an existing Article.
Expand Down
8 changes: 3 additions & 5 deletions internal/cli/cmdEmpty.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type CommandEmpty struct {
PermissionGroupID int `name:"permission-group-id" short:"p" help:"Specify the permission group ID. If not specified, the default value will be used."`
UserSegmentID *int `name:"user-segment-id" short:"u" help:"Specify the user segment ID. If not specified, the default value will be used."`
SaveArticle bool `name:"save-article" help:"It saves the article in addition to the translation."`
WithoutSectionDir bool `name:"without-section-dir" help:"It doesn't save in a directory named after the section ID."`
WithSectionDir bool `name:"with-section-dir" short:"S" help:"A .md file will be created in the section ID directory."`
client zendesk.Client `kong:"-"`
}

Expand Down Expand Up @@ -59,10 +59,8 @@ func (c *CommandEmpty) Run(g *Global) error {
return err
}

var saveDirPath string
if c.WithoutSectionDir {
saveDirPath = g.Config.ContentsDir
} else {
saveDirPath := g.Config.ContentsDir
if c.WithSectionDir {
saveDirPath = filepath.Join(g.Config.ContentsDir, strconv.Itoa(a.SectionID))
}

Expand Down
20 changes: 9 additions & 11 deletions internal/cli/cmdPull.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
)

type CommandPull struct {
Locale string `name:"locale" short:"l" help:"Specify the locale to pull. If not specified, the default locale will be used."`
Raw bool `name:"raw" help:"It pulls raw data without converting it from HTML to Markdown."`
SaveArticle bool `name:"save-article" short:"a" help:"It pulls and saves the article in addition to the translation."`
WithoutSectionDir bool `name:"without-section-dir" help:"It doesn't save in a directory named after the section ID."`
ArticleIDs []int `arg:"" help:"Specify the article IDs to pull." type:"int"`
client zendesk.Client `kong:"-"`
converter converter.Converter `kong:"-"`
Locale string `name:"locale" short:"l" help:"Specify the locale to pull. If not specified, the default locale will be used."`
Raw bool `name:"raw" help:"It pulls raw data without converting it from HTML to Markdown."`
SaveArticle bool `name:"save-article" short:"a" help:"It pulls and saves the article in addition to the translation."`
WithSectionDir bool `name:"with-section-dir" short:"S" help:"A .md file will be created in the section ID directory."`
ArticleIDs []int `arg:"" help:"Specify the article IDs to pull." type:"int"`
client zendesk.Client `kong:"-"`
converter converter.Converter `kong:"-"`
}

func (c *CommandPull) AfterApply(g *Global) error {
Expand All @@ -40,10 +40,8 @@ func (c *CommandPull) Run(g *Global) error {
return err
}

var saveDirPath string
if c.WithoutSectionDir {
saveDirPath = g.Config.ContentsDir
} else {
saveDirPath := g.Config.ContentsDir
if c.WithSectionDir {
saveDirPath = filepath.Join(g.Config.ContentsDir, strconv.Itoa(a.SectionID))
}

Expand Down
Loading