[NPMCLI-97] Copy command Created: 09/Feb/17  Updated: 24/Mar/22

Status: Open
Project: Magnolia CLI
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Neutral
Reporter: Christopher Zimmermann Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: to-specify
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Date of First Response:

 Description   

Command to copy entities.
mgnl copy

Features:

  • Copy light module including changing all old references (within the module) in yaml, ftl, i18n files from original module name to new one.
  • Copy component (copies template definition, ftl, dialog definition)
  • Copy page template.(copies template definition, ftl, dialog definition)

This would be a helpful timesaver.

To specify:

  • Command syntax.
  • How to reference things not in the immediate directory

2 ideas

  • Specify type: copy light-module oldname newname, copy component oldname newname
  • Do not specify type: copy oldname newname


 Comments   
Comment by Christopher Zimmermann [ 09/Mar/17 ]

tgregovsky robertkowalski Can you add thoughts about name of command?
I'm thinking that we would also want the ability to copy a component or a page - but I'm worried about having so many commands -
copy-light-module
copy-component
copy-page

That would be consistant with the create commands.
Eventually we might also want copy-app or copy-theme.
What about just adding one command "copy" that takes the type as the first parameter?

But then create and copy are different patterns.
Maybe create commands should also become "create".

(I think thats also more in line with other cli's like embers and angulars with "generate")

Your thoughts?

Comment by Robert Kowalski [ 09/Mar/17 ]

I believe the main reason to copy a light-module is to modify the included component. maybe frontools can confirm that?

I like the idea regarding "mgnl create <something>". it feels a lot more natural to type and think of the commands. +1 to go with this pattern from me. a possible migration strategy could be to have the old "create-" commands still available, but not advertising them.

Comment by Cédric Eberhardt [ 16/Mar/17 ]

Hi, I am also the one that prefer "mgnl add light-module", "mgnl clone light-module", "mgn remove light-module", etc... And you can support more than one command, like copy=clone=duplicate or create=add=new=init=generate for instance. Moreover this the way git, heroku, apt and others... work, so we are used to them.

"mgnl clone light-module slideshow slideshow2"
And then in slideshow2: "mgnl light-module set-name MyAwesomeSlideshow"

Or even more complicated you can let mgnl cli interact with light module's internal cli

Comment by Christopher Zimmermann [ 17/Mar/17 ]

On the other hand, do I need to specify type? Can I just specify the name?

mgnl copy the-light-module newname
mgnl copy the-fancy-component newname
mgnl copy the-terrible-page newname
mgnl copy the-small-app newname

Comment by Cédric Eberhardt [ 17/Mar/17 ]

If you can recognise what it is, yes, for sure. The less verbose, the better.

Comment by Robert Kowalski [ 21/Mar/17 ]

i like where this is going!

often a light-module has the same name as a component it contains.

explicitly stating what we are going to work with solves the problem at its root and additionally we don't have to implement fancy sniffing logic to find out which element we are referring to.

i would go for explicit mentionign the type we are going to work with, with auto-complete to make it easier to type

Generated at Mon Feb 12 04:46:30 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.