Revision 11c9a6c9
Added by Marc Dequènes over 15 years ago
- ID 11c9a6c91cc6e37cfde936422976b40e927a4b6b
TODO | ||
---|---|---|
- create item (aspect-less, with at least MUST fields with a field=val syntax, and multiple occurences of the same field allowed to specify multiple values for multi-valued fields)
|
||
- remove/add aspect (removing obsolete fields/adding new MUST fields accordingly)
|
||
- binary fields: allow upload from file (using field[+-]=path syntax in 'mod' operation when detecting binary field)
|
||
- search by combination of objects/aspects/fields values
|
||
- display familly information (preliminary work done for debug mode done, but object type should be recognized and displayed properly)
|
bin/shadowwalker | ||
---|---|---|
end
|
||
|
||
field_data = item.send(field_name)
|
||
field_data = [field_data] unless field_data.is_a?(Array)
|
||
|
||
result_is_binary = false
|
||
if file_no == "?"
|
||
result = field_data.size
|
||
else
|
||
... | ... | |
exit 2
|
||
end
|
||
|
||
result = (field_data.is_a?(Array) ? field_data[file_no] : field_data)
|
||
result = field_data[file_no]
|
||
result_is_binary = attr_info.binary?
|
||
end
|
||
|
||
if args.empty?
|
||
puts result
|
||
if result_is_binary
|
||
# output binary data without newline, so it can be pipped or redirected easily
|
||
STDOUT.write result
|
||
else
|
||
puts result
|
||
end
|
||
else
|
||
file_name = args.shift
|
||
if File.exists?(file_name)
|
||
... | ... | |
next
|
||
end
|
||
|
||
if attr_info.binary?
|
||
unless File.exists?(val)
|
||
STDERR.puts "The field '#{field}' contains binary data, you must provide a filename instead of a direct value."
|
||
exit 2
|
||
end
|
||
|
||
begin
|
||
val = File.read(val)
|
||
rescue
|
||
STDERR.puts "The file for the binary field '#{field}' cannot be read: " + $!
|
||
exit 2
|
||
end
|
||
end
|
||
|
||
old_val = item.send(field)
|
||
old_val = [old_val] unless old_val.is_a? Array
|
||
when 'rel'
|
||
... | ... | |
case type
|
||
when nil
|
||
new_val = old_val - [val]
|
||
item.send(field + "=", new_val)
|
||
when 'rel'
|
||
item.send(field).delete(val)
|
||
end
|
||
... | ... | |
begin
|
||
cmdparser.parse
|
||
rescue ActiveLdap::EntryInvalid => e
|
||
STDERR.puts e.to_s
|
||
# work around #26758
|
||
STDERR.puts e.to_s.sub(/invalid format: .*: required syntax:/, "invalid format. required syntax:")
|
||
exit 3
|
||
rescue ActiveLdap::OperationNotPermitted => e
|
||
STDERR.puts "You don't have enough rights for this operation."
|
Also available in: Unified diff
[evol/fix] added uploading of files for binary fields, fixed broken '-=' operator in the 'mod' command, fixed another index bug for the 'show' command, and modified the show commmand to display binary fields without newline (usefull for pipes or redirections)