Skip to content

Commit

Permalink
Merge pull request #51 from arrow2nd/add-skip-commnent-flag
Browse files Browse the repository at this point in the history
✨ (cmd/record) --no-comment を追加
  • Loading branch information
arrow2nd authored Jun 24, 2023
2 parents fdab53d + 752154d commit 29843f1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased]

## [v1.2.0] - 2023-06-24

### Added

- `record` コマンドに `--no-comment` を追加

## [v1.1.1] - 2023-06-18

### Fixed
Expand All @@ -28,6 +34,7 @@

- リリース 📺

[v1.2.0]: https://github.com/arrow2nd/anct/compare/v1.1.0...v1.2.0
[v1.1.1]: https://github.com/arrow2nd/anct/compare/v1.0.1...v1.1.1
[v1.1.0]: https://github.com/arrow2nd/anct/compare/v1.0.0...v1.1.0
[v1.0.0]: https://github.com/arrow2nd/anct/compare/v0.1.0...v1.0.0
15 changes: 8 additions & 7 deletions cmd/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func (c *Command) newCmdRecord() *cobra.Command {
r.Flags().BoolP("unwatch", "u", false, "select from the unwatched episodes of the work you are watching")
r.Flags().StringP("rating", "r", "", "episode rating: {great|good|average|bad}")
r.Flags().StringP("comment", "c", "", "comment")
r.Flags().BoolP("no-comment", "n", false, "skip comment input")

return r
}
Expand Down Expand Up @@ -49,16 +50,16 @@ func (c *Command) recordRun(cmd *cobra.Command, args []string) error {
return err
}

// コメント
comment := ""
if len(episodeIDs) == 1 {
// 記録するエピソードが1つの時のみコメントを受け取る
c, err := cmdutil.ReceiveBody(cmd.Flags(), "comment")
if err != nil {
noComment, _ := cmd.Flags().GetBool("no-comment")

// --no-comment が指定されていない & 記録するエピソードが1つの時のみコメントを受け取る
if !noComment && len(episodeIDs) == 1 {
if c, err := cmdutil.ReceiveBody(cmd.Flags(), "comment"); err != nil {
return err
} else {
comment = c
}

comment = c
}

// 確認
Expand Down

0 comments on commit 29843f1

Please sign in to comment.