|
| 1 | +--!A cross-platform build utility based on Lua |
| 2 | +-- |
| 3 | +-- Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +-- you may not use this file except in compliance with the License. |
| 5 | +-- You may obtain a copy of the License at |
| 6 | +-- |
| 7 | +-- http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +-- |
| 9 | +-- Unless required by applicable law or agreed to in writing, software |
| 10 | +-- distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +-- See the License for the specific language governing permissions and |
| 13 | +-- limitations under the License. |
| 14 | +-- |
| 15 | +-- Copyright (C) 2015-present, TBOOX Open Source Group. |
| 16 | +-- |
| 17 | +-- @author ruki |
| 18 | +-- @file archive.lua |
| 19 | +-- |
| 20 | + |
| 21 | +-- imports |
| 22 | +import("core.base.option") |
| 23 | +import("utils.archive.archive") |
| 24 | + |
| 25 | +-- the options |
| 26 | +local options = { |
| 27 | + {nil, "compress", "kv", nil, "Set the compress algorithm.", values = {"fastest", "faster", "default", "better", "best"}}, |
| 28 | + {'r', "recurse", "k", nil, "Enable recursive pattern."}, |
| 29 | + {nil, "excludes", "kv", nil, "Set the excludes patterns.", |
| 30 | + "e.g.", |
| 31 | + " - xmake l cli.archive --excludes=\"*/dir/*|dir/*\" -o archivefile inputfiles"}, |
| 32 | + {'o', "archivefile","kv", nil, "The output archive file."}, |
| 33 | + {nil, "inputfiles", "vs", nil, "The input files."} |
| 34 | +} |
| 35 | + |
| 36 | +function main(...) |
| 37 | + local argv = table.pack(...) |
| 38 | + local args = option.parse(argv, options, "Archive file.", |
| 39 | + "", |
| 40 | + "Usage: xmake l cli.archive [options]") |
| 41 | + local archivefile = assert(args.archivefile, "please set output file!") |
| 42 | + local inputfiles = assert(args.inputfiles, "please set input files!") |
| 43 | + |
| 44 | + local opt = {} |
| 45 | + opt.recurse = args.recurse |
| 46 | + opt.compress = args.compress |
| 47 | + if args.excludes then |
| 48 | + opt.excludes = args.excludes:split("|") |
| 49 | + end |
| 50 | + archive(archivefile, inputfiles, opt) |
| 51 | +end |
0 commit comments