Skip to content

Commit

Permalink
Merge pull request #1 from arrow2nd/develop
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
arrow2nd committed Dec 20, 2021
2 parents 1395c5a + ee7d739 commit c33c31f
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 9 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## [Unreleased]

## [1.1.0] - 2021-12-20

### Added

- 設定中のデフォルト値を表示する`config list`コマンドを追加

### Changed

- 項目選択時のメッセージ文を微調整

## [1.0.0] - 2021-12-19

- リリースしました!
31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

![codic-cli](https://user-images.githubusercontent.com/44780846/146678773-5c518844-f5b9-4ada-a2b4-db3c50a02fc7.gif)

## 必要なもの

[codic](https://codic.jp/)の API キーが必要です。[こちら](https://codic.jp/my/api_status)から取得してください。

## インストール

### Homebrew
Expand All @@ -27,19 +31,38 @@ brew install codic

### get

`get [<日本語>] [--case 名前付け規則] [--prefix 接頭辞のスタイル]`
`get [<日本語>] [--case 名前付け規則] [--prefix 接頭辞スタイル]`

ネーミングを生成します。

```sh
$ codic こんにちは世界 --case snake --prefix camel
```txt
$ codic get こんにちは世界 --case snake --prefix camel
hello_world
```

フラグを省略すると設定したデフォルト値に基づいて生成されます。

また、ネーミングの生成に失敗した場合でもそのまま出力します。

#### 名前付け規則のパラメータ

| パラメータ名 | 規則名 ||
| ------------ | ---------------------------- | ---------- |
| pascal | パスカルケース | PascalCase |
| camel | キャメルケース | camelCase |
| snake | スネークケース | snake_case |
| screaming | スクリーミングスネークケース | SNAKE_CASE |
| kebab | ケバブケース | kebab-case |
| space | なし(スペース区切り) | space case |

#### 接頭辞スタイルのパラメータ

| パラメータ名 | 説明 ||
| ------------ | ------------------------------- | ----------- |
| microsoft | MS ネーミングガイドラインに準拠 | IOException |
| camel | CamelCase のルールに準拠 | IoException |
| literal | リテラル(変換しない) | |

### config api

API キーを設定します。
Expand All @@ -50,4 +73,4 @@ API キーを設定します。

### config prefix

デフォルトの接頭辞のスタイルを設定します
デフォルトの接頭辞スタイルを設定します
1 change: 1 addition & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func (c *Cmd) newConfigCmd() *cobra.Command {
c.newConfigAPICmd(),
c.newConfigCaseCmd(),
c.newConfigPrefixCmd(),
c.newConfigListCmd(),
)

return configCmd
Expand Down
4 changes: 2 additions & 2 deletions cmd/config_case.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ var caseList = list.List{
func (c *Cmd) newConfigCaseCmd() *cobra.Command {
return &cobra.Command{
Use: "case",
Short: "Set the case type",
Short: "Set the default case type",
Args: cobra.NoArgs,
RunE: c.execConfigCaseCmd,
}
}

func (c *Cmd) execConfigCaseCmd(cmd *cobra.Command, args []string) error {
result := caseList.SelectList("Case type")
result := caseList.SelectList("Default Case Type?")
if result == "" {
return nil
}
Expand Down
27 changes: 27 additions & 0 deletions cmd/config_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cmd

import (
"fmt"

"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

func (c *Cmd) newConfigListCmd() *cobra.Command {
return &cobra.Command{
Use: "list",
Short: "Display the current setting parameters",
Args: cobra.NoArgs,
Run: c.execConfigListCmd,
}
}

func (c *Cmd) execConfigListCmd(cmd *cobra.Command, args []string) {
showValue("Case Type", "case")
showValue("Prefix Style", "prefix")
}

func showValue(title, valueName string) {
fmt.Printf("%s %s\n", color.HiBlackString("%s:", title), viper.GetString(valueName))
}
4 changes: 2 additions & 2 deletions cmd/config_prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ var prefixList = list.List{
func (c *Cmd) newConfigPrefixCmd() *cobra.Command {
return &cobra.Command{
Use: "prefix",
Short: "Set the prefix style",
Short: "Set the default prefix style",
Args: cobra.NoArgs,
RunE: c.execConfigPrefixCmd,
}
}

func (c *Cmd) execConfigPrefixCmd(cmd *cobra.Command, args []string) error {
result := prefixList.SelectList("Prefix style")
result := prefixList.SelectList("Default Prefix Style?")
if result == "" {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/constants.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd

// Version バージョン
const Version = "1.0.0"
const Version = "1.1.0"

0 comments on commit c33c31f

Please sign in to comment.