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(cli): add create piece functionality #300

Merged
merged 2 commits into from
Jun 20, 2024

Conversation

tdari
Copy link
Contributor

@tdari tdari commented Jun 3, 2024

This PR will add create piece functionality to domino-cli. Users will be able to create boilerplate code necessary for the new pieces using this command: domino piece-repository pieces create --name <name>

@nathan-vm
Copy link
Collaborator

This looks like a great feature, well done @tdari 🚀

@tdari tdari force-pushed the feat/add_piece_command branch from e46d6aa to a4fc825 Compare June 4, 2024 17:50
@tdari tdari marked this pull request as ready for review June 4, 2024 17:51
@vinicvaz vinicvaz self-requested a review June 4, 2024 18:31
def _validate_piece_name(name: str):
if len(name) == 0:
raise ValidationError(f"Piece name must have at least one character.")
regex = r'^[A-Za-z_][A-Za-z0-9_]*$'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe I'm wrong @vinicvaz but I think the piece name should end with "Piece" right ?

Like: "FooBarPiece"

Copy link
Collaborator

@vinicvaz vinicvaz left a comment

Choose a reason for hiding this comment

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

Hey @tdari this is really good and useful, thanks for submitting.
What you think about removing the pieces cli from the piece-repository nesting? I think we don't need this dependency since the CLI will execute on the current folder.
This usage looks simpler to me:

domino pieces --create <name>

What you think about that?

Comment on lines 293 to 300
def cli_pieces(ctx):
console.print("Manage piece folders.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can add a docstring to be shown in the CLI interface.
Something like:

Suggested change
def cli_pieces(ctx):
console.print("Manage piece folders.")
def cli_pieces(ctx):
"""Manage pieces in a repository."""
console.print("Manage piece folders.")

@tdari
Copy link
Contributor Author

tdari commented Jun 4, 2024

Hey @tdari this is really good and useful, thanks for submitting. What you think about removing the pieces cli from the piece-repository nesting? I think we don't need this dependency since the CLI will execute on the current folder. This usage looks simpler to me:

domino pieces --create <name>

What you think about that?

I also think the current version is a little bit made it longer, your suggestion can work but I think the cli shouldn't be dependent on the directory it has been called (even though its dependent right now). We can add a repository option to specify which repository this new piece will be added to, like, domino repository pieces create --repository <path_to_repo> --name <name> this will give us flexibility and programmability of the cli in the future use cases IMO. For that reason, I think we should specify the pieces command under the repository because there is a hierarchy. Maybe we can work on a different pr and re-design cli specifications. I was planning to refactor cli in that regard. I'd like to hear your opinions too.

@tdari tdari marked this pull request as draft June 4, 2024 19:18
@vinicvaz
Copy link
Collaborator

vinicvaz commented Jun 4, 2024

@tdari I agree with that accepting repository path to the pieces creation is the best.
I'm not sure yet about the need of the dependency on piece repository CLI in this case, but by now lets keep the hierarchy you mentioned. Something like should be enough:

domino piece-repository pieces create --name <name> --repository_path <path> 
# optional path, if none use cwd

Are you planning to add the path argument in this PR?

Also, feel free to send a PR including this in the docs here https://github.com/Tauffer-Consulting/domino-docs

@tdari
Copy link
Contributor Author

tdari commented Jun 4, 2024

@vinicvaz yes I'll re-open this again including all the revisions. Thank you.

@tdari tdari force-pushed the feat/add_piece_command branch from a4fc825 to 00f57bf Compare June 7, 2024 19:29
@tdari tdari force-pushed the feat/add_piece_command branch 3 times, most recently from 9d593da to fed4636 Compare June 9, 2024 17:01
@vinicvaz
Copy link
Collaborator

vinicvaz commented Jun 10, 2024

@tdari great you are adding tests!
Also, I discussed with @luiztauffer and we decided to go on with the simpler (less verbose) CLI without the nested.
So I think this PR can update the following:
domino pieces to domino pieces-repository to store all CLI actions for pieces repositories
and
domino pieces-repository pieces to domino pieces to store all actions related to pieces. We can pass the repository as an argument like described before.
an example of use would be domino pieces create --name my-piece --repository_path path/to/repo
With this we keep it more concise and easier

@tdari
Copy link
Contributor Author

tdari commented Jun 10, 2024

@vinicvaz it looks good to me. what about making it even shorter by using just repository instead of piece-repository. domino repository pieces, I think users will have enough context to recognize that is about piece repository. We can clearly indicate that in help messages.
What do you think?

@vinicvaz
Copy link
Collaborator

I aggree users probably will understand but as we are using Pieces Repository in almost everywhere (docs, code, etc) I think it will be better to keep pieces-repository . Basically applying the explicit better than implicit rule for this

@luiztauffer
Copy link
Member

nice work here @tdari !

@tdari tdari force-pushed the feat/add_piece_command branch from fed4636 to 520bd94 Compare June 14, 2024 19:09
@tdari tdari force-pushed the feat/add_piece_command branch from 520bd94 to 75df892 Compare June 14, 2024 19:15
@tdari tdari marked this pull request as ready for review June 14, 2024 19:17
Copy link
Collaborator

@vinicvaz vinicvaz left a comment

Choose a reason for hiding this comment

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

Nice work @tdari thanks for submitting this!

@vinicvaz vinicvaz merged commit 8ceb86e into Tauffer-Consulting:dev Jun 20, 2024
@vinicvaz vinicvaz mentioned this pull request Jun 20, 2024
3 tasks
@tdari
Copy link
Contributor Author

tdari commented Jun 20, 2024

Thanks, @vinicvaz. I checked the docs as you suggested, but I didn't want to add the new feature to the docs since there was only a paragraph mentioning the CLI. We can add it later once the CLI becomes mature enough, or we can write a post in the blog section to show users how they can create their pieces and mention these features there.

@tdari tdari deleted the feat/add_piece_command branch June 20, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants