From 0348646acd2fa28ace2c983e484bda57ceea90fd Mon Sep 17 00:00:00 2001 From: Anton Nesterov Date: Sat, 11 Feb 2023 14:57:07 +0300 Subject: [PATCH] add help; add readme --- pickit.ts | 20 ++++++++++-- readme.md | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 112 insertions(+), 5 deletions(-) diff --git a/pickit.ts b/pickit.ts index 0f2d2d2..cefde4a 100644 --- a/pickit.ts +++ b/pickit.ts @@ -8,6 +8,8 @@ import { cleanFetchCache, write } from "./mod.ts"; if (Deno.args.length == 1) { if (Deno.args[0] == "clean") { await cleanFetchCache(); + } else if (Deno.args[0] == "help") { + printHelp(); } else { const config = await import(Deno.args[0]); await write(config.default); @@ -16,16 +18,28 @@ if (Deno.args.length == 1) { const [source, output, ...pick] = Deno.args; await write([{ source, output, pick }]); } else { + printHelp(); +} + +function printHelp() { console.log( ` %cPickIt `, "font-size: 1.5em; font-weight: bold", ); - console.log(` + console.log( + ` This utility helps you to extract files from tarballs and github repos using glob syntax or regular expressions. You can use either a config file or command line arguments. - `); + + pickit %cclean - cleans the cache of fetched files. + %cpickit %chelp - prints this help message. + `, + "color: #ccb;", + "", + "color: #ccb;", + ); console.log( ` %cUsage: @@ -74,7 +88,7 @@ if (Deno.args.length == 1) { }, ] as PickConfig; - + `, "color: #aab;", ); diff --git a/readme.md b/readme.md index 54dd389..1622238 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,96 @@ -# Pick [WIP] +# Pick it -Pick files from remote sources +This utility helps you to extract files from tarballs and github repos using +glob syntax or regular expressions. You can use either a config file or command +line arguments. + +## Examples + +> Pick files from a github repo to directory `scripts`: + +```bash +pickit nesterow/pickit@v0.0.1a scripts **/tests/*.ts +``` + +> Pick files from a tarball to directory `logs`: + +```bash +pickit server_logs.tar.gz logs **/error.log +``` + +## Installation + +```bash +deno install -A https://deno.land/x/pickit/pickit.ts +``` + +## Using without installation + +```bash +deno run -A https://deno.land/x/pickit/pickit.ts [args]... +``` + +## Using config file + +If you need to pick files from multiple sources, you can use a config file. The +config file should exportan array of `PickConfig` objects. + +```typescript +// config.ts +import type { PickConfig } from "https://deno.land/x/pickit/mod.d.ts"; +export default [ + { + source: "username/repo@version", + output: "./outputDir", + pick: [ + /^.*/base/.*.css$/, // can be a regular expression + "/src/index.js", + "/src/**/*.yaml" + ], + }, +] as PickConfig; +``` + +See the complete example +[here](https://github.com/nesterow/pickit/blob/main/tests/config_mock.ts). + +> Usage: + +```bash +pickit ./config.ts +``` + +## API + +Most methods are exported from `mod.ts` and can be used within your code. Read +the [API documentation](https://deno.land/x/pickit/mod.ts) + +## License + +```text +MIT License + +Copyright (c) 2023 Pick it contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +## Contributors + +[@nesterow](https://github.com/nesterow)