Changeset 117 for trunk/lua/cli.lua
- Timestamp:
- 01/23/12 07:13:52 (16 months ago)
- File:
-
- 1 edited
-
trunk/lua/cli.lua (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lua/cli.lua
r115 r117 594 594 }, 595 595 { 596 names={'mdownload','mdl'}, 597 help='download file/directories from the camera', 598 arghelp="[options] <remote, remote, ...> <target dir>", 599 args=argparser.create{ 600 fmatch=false, 601 dmatch=false, 602 rmatch=false, 603 nodirs=false, 604 maxdepth=100, 605 }, 606 help_detail=[[ 607 <remote...> files/directories to download 608 <target dir> directory to download into 609 options: 610 -fmatch=<pattern> download only file with names matching <pattern> 611 -dmatch=<pattern> only create directories with names matching <pattern> 612 -rmatch=<pattern> only recurse into directories with names matching <pattern> 613 -nodirs only create directories 614 -maxdepth=n only recurse into N levels of directory 615 note <pattern> is a lua pattern, not a filesystem glob like *.JPG 616 ]], 617 618 func=function(self,args) 619 if #args < 2 then 620 return false,'expected source(s) and destination' 621 end 622 local dst=table.remove(args) 623 local srcs={} 624 for i,v in ipairs(args) do 625 srcs[i]=fsutil.make_camera_path(v) 626 end 627 -- TODO some of these need translating, so can't pass direct 628 local opts={ 629 fmatch=args.fmatch, 630 dmatch=args.dmatch, 631 rmatch=args.rmatch, 632 dirs=not args.nodirs, 633 maxdepth=tonumber(args.maxdepth), 634 } 635 return con:mdownload(srcs,dst,opts) 636 end, 637 }, 638 { 639 names={'mupload','mup'}, 640 help='upload file/directories to the camera', 641 arghelp="[options] <local, local, ...> <target dir>", 642 args=argparser.create{ 643 fmatch=false, 644 dmatch=false, 645 rmatch=false, 646 nodirs=false, 647 maxdepth=100, 648 pretend=false, 649 }, 650 help_detail=[[ 651 <local...> files/directories to upload 652 <target dir> directory to upload into 653 options: 654 -fmatch=<pattern> upload only file with names matching <pattern> 655 -dmatch=<pattern> only create directories with names matching <pattern> 656 -rmatch=<pattern> only recurse into directories with names matching <pattern> 657 -nodirs only create directories 658 -maxdepth=n only recurse into N levels of directory 659 -pretend print actions instead of doing them 660 note <pattern> is a lua pattern, not a filesystem glob like *.JPG 661 ]], 662 663 func=function(self,args) 664 if #args < 2 then 665 return false,'expected source(s) and destination' 666 end 667 local dst=fsutil.make_camera_path(table.remove(args)) 668 local srcs={} 669 -- args has other stuff in it, copy array parts 670 srcs={unpack(args)} 671 -- TODO some of these need translating, so can't pass direct 672 local opts={ 673 fmatch=args.fmatch, 674 dmatch=args.dmatch, 675 rmatch=args.rmatch, 676 dirs=not args.nodirs, 677 maxdepth=tonumber(args.maxdepth), 678 pretend=args.pretend, 679 } 680 return con:mupload(srcs,dst,opts) 681 end, 682 }, 683 { 684 names={'delete','rm'}, 685 help='delete file/directories from the camera', 686 arghelp="[options] <target, target,...>", 687 args=argparser.create{ 688 fmatch=false, 689 dmatch=false, 690 rmatch=false, 691 nodirs=false, 692 maxdepth=100, 693 pretend=false, 694 ignore_errors=false, 695 skip_topdirs=false, 696 }, 697 help_detail=[[ 698 <target...> files/directories to remote 699 options: 700 -fmatch=<pattern> upload only file with names matching <pattern> 701 -dmatch=<pattern> only delete directories with names matching <pattern> 702 -rmatch=<pattern> only recurse into directories with names matching <pattern> 703 -nodirs don't delete drictories recursed into, only files 704 -maxdepth=n only recurse into N levels of directory 705 -pretend print actions instead of doing them 706 -ignore_errors don't abort if delete fails, continue to next item 707 -skip_topdirs don't delete directories given in command line, only contents 708 note <pattern> is a lua pattern, not a filesystem glob like *.JPG 709 ]], 710 711 func=function(self,args) 712 if #args < 1 then 713 return false,'expected at least one target' 714 end 715 -- args has other stuff in it, copy array parts 716 local tgts={} 717 for i,v in ipairs(args) do 718 tgts[i]=fsutil.make_camera_path(v) 719 end 720 -- TODO some of these need translating, so can't pass direct 721 local opts={ 722 fmatch=args.fmatch, 723 dmatch=args.dmatch, 724 rmatch=args.rmatch, 725 dirs=not args.nodirs, 726 maxdepth=tonumber(args.maxdepth), 727 pretend=args.pretend, 728 ignore_errors=args.ignore_errors, 729 skip_topdirs=args.skip_topdirs, 730 } 731 -- TODO use msg_handler to print as they are deleted instead of all at the end 732 local results,err = con:mdelete(tgts,opts) 733 if not results then 734 return false,err 735 end 736 for i,v in ipairs(results) do 737 printf("%s: ",v.file) 738 if v.status then 739 printf('OK') 740 else 741 printf('FAILED') 742 end 743 if v.msg then 744 printf(": %s",v.msg) 745 end 746 printf('\n') 747 end 748 return true 749 end, 750 }, 751 { 596 752 names={'version','ver'}, 597 753 help='print API versions',
Note: See TracChangeset
for help on using the changeset viewer.