phpcr / phpcr-utils

A set of helper classes and command line commands you want to use with phpcr, but that are not part of the API itself
phpcr.github.io
Other
72 stars 30 forks source link

Added "touch" command #53

Closed dantleech closed 11 years ago

dantleech commented 11 years ago

Enables:

This command could I guess also encompass adding and removing mixins.

$ ./bin/phpcr phpcr:touch /foobar-123                                      
Creating node:  /foobar-123 [nt:unstructured]
$ ./bin/phpcr phpcr:touch /foobar --type=nt:unstructured --set=bar=myvalue --unset=foo --dump --set=dtl=ltd 
Node at path /foobar already exists and has primary type nt:unstructured.
 > Setting property bar to myvalue
 > Setting property dtl to ltd
 > Unsetting property foo
Node dump: 
 - bar = myvalue
 - jcr:primaryType = nt:unstructured
 - dtl = ltd
lsmith77 commented 11 years ago

would be cool to make this command interactive

dbu commented 11 years ago

very cool, thanks! i wonder a bit about the --set=x=y syntax (two equal signs). but i don't see an obvious alternative, : is used for namespaces. or can the console also do --set x=y ? and will all this work correctly if i quote things, i.e. when having spaces. like --set="node name"="my value"

regarding interactive: that sounds good, but i would be happy to merge this as is for now. i think the best interactive experience would be a web based phpcr browser, maybe we should rather invest in those old unfinished PRs for a phpcr browser first.

dantleech commented 11 years ago

I doubt if quoting would work, but I'll test it.

What do you think about expanding further to include add/remove mixins?

David Buchmann notifications@github.com a écrit :

very cool, thanks! i wonder a bit about the --set=x=y syntax (two equal signs). but i don't see an obvious alternative, : is used for namespaces. or can the console also do --set x=y ? and will all this work correctly if i quote things, i.e. when having spaces. like --set="node name"="my value"

regarding interactive: that sounds good, but i would be happy to merge this as is for now. i think the best interactive experience would be a web based phpcr browser, maybe we should rather invest in those old unfinished PRs for a phpcr browser first.


Reply to this email directly or view it on GitHub: https://github.com/phpcr/phpcr-utils/pull/53#issuecomment-17007695

Envoyé de mon téléphone Android avec K-9 Mail. Excusez la brièveté.

dbu commented 11 years ago

the functionality makes sense. however we get far away from the meaning of the current name. already setting a property goes beyond "touch". i wonder if we should call it "doctrine:phpcr:node:modify" or something like that.

maybe we could split this and say doctrine:phpcr:node:touch can just create (including primary type, as that is immutable afterwards afaik) but setting properties and mixins and whatnot is node:modify? and the move would be node:move one day...

dantleech commented 11 years ago

I think the meaning of "touch" is sufficiently vague to encompass both create and update. I think the original unix program can change file access and timestamps in addition to creating empty files, and these are effectively properties of the file.

"modify" would give the wrong impression, and having both "create" and "modify" seems like uncessary duplication of code, in addition to being more fiddly when re-executing the command.

I was tempted to add a --remove option as a convenience method, in which case the command would be a node swiss army knife. But decided against it.

Move should certainly have its own command.

If we are happy with the name I will add --add-mixin and --remove-mixin and also --session.

dbu commented 11 years ago

alright, i can live with it being called touch. remove is covered by "purge", where you can specify a path.

add-mixin and remove-mixin make sense. i think session is a good point, but only relevant for the phpcr-odm adaption of the command, or not?

about the setting of values and the repeated equals and quoting for spaces, what did you find out?

dantleech commented 11 years ago

Updated. Added [add|remove]-mixin. Tested the quoting, and that seems to work, also notice that if you use the shortcut the first "=" is not required, and indeed will break things if used.

--set="Foo Bar"="Bar Foo" # OK
-s "Foo Bar"="Bar Foo" # OK
-s="Foo Bar"="Bar Foo" # ERROR!

Have also added command for listing node types, PR to follow.

dbu commented 11 years ago

good that quoting works. the -s variant looks much better than the --set with two = signs, but guess we can do nothing about that.

i think this is good to merge, but its in conflict as well (because the new command is always added to the end of the list, i guess. maybe you can add the list node types command next to the register node types command, order them semantically rather than historically...)

dantleech commented 11 years ago

Rebased.