2026-04-15 09:27:34 +02:00
|
|
|
# -*- 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')
|
2026-04-16 13:34:59 +02:00
|
|
|
parser.add_argument('-F', '--fixed-strings', action='store_true',
|
|
|
|
|
help='Don\'t expand platform info macros in <src> and <dst>')
|
2026-04-15 09:27:34 +02:00
|
|
|
|
|
|
|
|
async def _run(self, args: Namespace) -> None:
|
2026-04-16 13:34:59 +02:00
|
|
|
def __expand(url: str) -> str:
|
|
|
|
|
if args.fixed_strings:
|
|
|
|
|
return url
|
|
|
|
|
return self.app.distro_info(url)
|
|
|
|
|
await copy(__expand(args.src), __expand(args.dst),
|
2026-04-17 15:05:42 +02:00
|
|
|
owner=args.owner, group=args.group, mode=int(args.mode, 0))
|