Skip to content

Commit 5a3765c

Browse files
authored
Merge pull request #12 from tukaelu/refactor/flag-with-section-dir
refactor: change flag for section directory
2 parents 84ff634 + 5a3dc4a commit 5a3765c

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ Flags:
9393
-l, --locale=STRING Specify the locale to pull. If not specified, the default locale will be used.
9494
--raw It pulls raw data without converting it from HTML to Markdown.
9595
-a, --save-article It pulls and saves the article in addition to the translation.
96-
--without-section-dir It doesn't save in a directory named after the section ID.
96+
--with-section-dir A .md file will be created in the section ID directory.
9797
```
9898

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

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

121121
The empty subcommand should not be used when adding a new Translation to an existing Article.

internal/cli/cmdEmpty.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type CommandEmpty struct {
1515
PermissionGroupID int `name:"permission-group-id" short:"p" help:"Specify the permission group ID. If not specified, the default value will be used."`
1616
UserSegmentID *int `name:"user-segment-id" short:"u" help:"Specify the user segment ID. If not specified, the default value will be used."`
1717
SaveArticle bool `name:"save-article" help:"It saves the article in addition to the translation."`
18-
WithoutSectionDir bool `name:"without-section-dir" help:"It doesn't save in a directory named after the section ID."`
18+
WithSectionDir bool `name:"with-section-dir" short:"S" help:"A .md file will be created in the section ID directory."`
1919
client zendesk.Client `kong:"-"`
2020
}
2121

@@ -59,10 +59,8 @@ func (c *CommandEmpty) Run(g *Global) error {
5959
return err
6060
}
6161

62-
var saveDirPath string
63-
if c.WithoutSectionDir {
64-
saveDirPath = g.Config.ContentsDir
65-
} else {
62+
saveDirPath := g.Config.ContentsDir
63+
if c.WithSectionDir {
6664
saveDirPath = filepath.Join(g.Config.ContentsDir, strconv.Itoa(a.SectionID))
6765
}
6866

internal/cli/cmdPull.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import (
1010
)
1111

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

2222
func (c *CommandPull) AfterApply(g *Global) error {
@@ -40,10 +40,8 @@ func (c *CommandPull) Run(g *Global) error {
4040
return err
4141
}
4242

43-
var saveDirPath string
44-
if c.WithoutSectionDir {
45-
saveDirPath = g.Config.ContentsDir
46-
} else {
43+
saveDirPath := g.Config.ContentsDir
44+
if c.WithSectionDir {
4745
saveDirPath = filepath.Join(g.Config.ContentsDir, strconv.Itoa(a.SectionID))
4846
}
4947

0 commit comments

Comments
 (0)