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

feat: add command in charmil cli #207

Merged
merged 5 commits into from Aug 9, 2021
Merged

feat: add command in charmil cli #207

merged 5 commits into from Aug 9, 2021

Conversation

ankithans
Copy link
Member

@ankithans ankithans commented Aug 7, 2021

Closes #166

Description

  • Add command in charmil CLI
  • Refactor charmil CLI

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation change
  • Other (please specify)

Checklist

  • Documentation added for the feature
  • CI and all relevant tests are passing
  • Code Review completed
  • Verified independently by reviewer

image

@ankithans ankithans added enhancement New feature or request WIP work in progress labels Aug 7, 2021
@ankithans ankithans added this to the Charmil CLI - shell commands milestone Aug 7, 2021
@ankithans ankithans self-assigned this Aug 7, 2021
@wtrocki
Copy link
Contributor

wtrocki commented Aug 7, 2021

Very nice!

@ankithans ankithans marked this pull request as ready for review August 8, 2021 12:50
@ankithans ankithans requested review from namit-chandwani and a team August 8, 2021 12:50
@namit-chandwani
Copy link
Member

namit-chandwani commented Aug 9, 2021

The add command fails when any of the parent directories in --cmdPath flag doesn't exist.

Logs:

>> ./charmil add --cmdName="mycmd" --cmdPath="./cmd"

Usage:
  charmil add [flags]

Examples:
$ charmil add cliname

Flags:
  -s, --cmdName string   name of the new command
  -c, --cmdPath string   command path where you want to create the command (default ".")
  -h, --help             help for add

mkdir cmd/mycmd: no such file or directory

I had a similar issue with the crud command. Mentioning the PR which fixed it (for reference): #192

Just replacing os.Mkdir with os.MkdirAll (while creating the dir) should be able to fix this mostly.


// Adds local flags
cmd.Flags().StringVarP(&tmplData.CmdPath, f.Localizer.LocalizeByID("add.flag.cmdPath.name"), "c", ".", f.Localizer.LocalizeByID("add.flag.cmdPath.description"))
cmd.Flags().StringVarP(&tmplData.CmdName, f.Localizer.LocalizeByID("add.flag.cmdName.name"), "s", "", f.Localizer.LocalizeByID("add.flag.cmdName.description"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can add a flag here that takes a target path for the language file and then generate the file in that location.
The crud command does this too. Check this out for reference.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, we can leave it? it would be difficult for the user to give two paths. It's just a file, user can move it wherever they wants manually.

it will be better to generate the locales file with the command file. to let the user figure out what really happened.


import "embed"

// CrudTemplates stores embedded contents of all the add template files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// CrudTemplates stores embedded contents of all the add template files
// AddTemplates stores embedded contents of all the add template files

@@ -0,0 +1,25 @@
add.cmd.use:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is outside the scope of this PR, but should we localize the use of command?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not sure about this. It's being done in rhoas as well.

@wtrocki wtrocki closed this Aug 9, 2021
@wtrocki wtrocki deleted the charmil-add branch August 9, 2021 08:51
@ankithans
Copy link
Member Author

should we merge this @wtrocki ?

@wtrocki wtrocki restored the charmil-add branch August 9, 2021 10:12
@wtrocki wtrocki reopened this Aug 9, 2021
@wtrocki wtrocki merged commit f706d09 into main Aug 9, 2021
@wtrocki wtrocki deleted the charmil-add branch August 9, 2021 10:12
@wtrocki
Copy link
Contributor

wtrocki commented Aug 9, 2021

Ok.. Rush doesn't help. Release needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request requires-release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Charmil add command
4 participants