mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 17:23:36 +02:00
cmds.posix.CmdCopy: Add module
Add CmdCopy, designed to copy data from the filesystem to another location in the filesystem. Not necessarily local file systems, the URLs can be all URLs supported by ExecContext.run(). Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
16bb4e5bed
commit
e811b2dc14
1 changed files with 27 additions and 0 deletions
27
src/python/jw/pkg/cmds/posix/CmdCopy.py
Normal file
27
src/python/jw/pkg/cmds/posix/CmdCopy.py
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from ...lib.util import copy
|
||||||
|
from .Cmd import Cmd
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..CmdPosix import CmdPosix
|
||||||
|
from argparse import Namespace, ArgumentParser
|
||||||
|
|
||||||
|
class CmdCopy(Cmd): # export
|
||||||
|
|
||||||
|
def __init__(self, parent: CmdPosix) -> None:
|
||||||
|
super().__init__(parent, 'copy', help="Copy files")
|
||||||
|
|
||||||
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||||
|
super().add_arguments(parser)
|
||||||
|
parser.add_argument('src', help='Source file URI')
|
||||||
|
parser.add_argument('dst', help='Destination file URI')
|
||||||
|
parser.add_argument('-o', '--owner', default=None, help='Destination file owner')
|
||||||
|
parser.add_argument('-g', '--group', default=None, help='Destination file group')
|
||||||
|
parser.add_argument('-m', '--mode', default=None, help='Destination file mode')
|
||||||
|
|
||||||
|
async def _run(self, args: Namespace) -> None:
|
||||||
|
await copy(args.src, args.dst, owner=args.owner, group=args.group, mode=args.mode)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue