phpcr / phpcr-shell

PHPCR Shell
MIT License
69 stars 19 forks source link

Support globbing #80

Closed dantleech closed 9 years ago

dantleech commented 10 years ago

It would be great to support at least wildcards:

PHPCRSH> node:remove *
PHPCRSH> node:remove foobar*

PHPCRSH> node:remove en_us/*

If not something more complete, I wonder if there are any libraries for this

dbu commented 10 years ago

for direct children, phpcr itself supports globbing

dantleech commented 10 years ago

Yep: http://www.day.com/specs/jcr/2.0/5_Reading.html#5.2.2.1 Name Patterns

I think it would be relatively simple to implement something which expands paths containing globs, e.g. it should be possible to support:

PHPCRSH> ls /*/foo/*
PHPCRSH> rm *.txt
PHPCRSH> cp foo* foo/

We would just have to implement something which resolves a globbed path to an array of nodes.

The only implementation difficulty I can see is determining if a given path segment is a glob or not:

  1. We could first check to see if the given node exists and if it doesn't check if the parent exists - if the parent exists we assume the suffix is a glob.
  2. If the basename contains a * character then treat as a glob.
  3. Always treat the basename as a glob, unless there is a concrete node at the given path
dbu commented 10 years ago

i would only glob when there is an explicit *. otherwise there are too many ambiguities. * is not valid in a node name, or is it?

dantleech commented 9 years ago

Also would be great to do something like:

PHPCRSH> ls /cmf/foobar/contents/articles/*/jcr:uuid
dantleech commented 9 years ago

Closing in favor of PR #113