From 012dfbd4dcb04bac2aa5d065328bf0197a22f6ce Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Wed, 25 Nov 2015 21:44:42 -0500 Subject: [PATCH 1/7] added cli --- README.md | 26 ++++++++++++++++++ cli.js | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 5 +++- 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 cli.js diff --git a/README.md b/README.md index 22946e5..29e4e56 100644 --- a/README.md +++ b/README.md @@ -58,4 +58,30 @@ wget({ ); ``` +## CLI + +Install: + +```bash +$ npm install -g wgetjs +``` + +Use: + +```text +Usage: wget [options] [url]... + +Ultra simple async retrieval of remote files over http or https + +Options: + + -h, --help output usage information + -v, --version output version number + +Usage: + +# Download file +$ wget https://github.com/NodeOS/NodeOS/archive/master.zip +``` + ## License: MIT diff --git a/cli.js b/cli.js new file mode 100644 index 0000000..1c212e6 --- /dev/null +++ b/cli.js @@ -0,0 +1,77 @@ +#!/usr/bin/env node +'use strict'; + +/* eslint-disable no-process-exit */ + +/* + * Dependencies. + */ + +var wget = require('./'); +var pack = require('./package.json'); + +/* + * Arguments. + */ + +var argv = process.argv.slice(2); + +/* + * Command. + */ + +var command = Object.keys(pack.bin)[0]; + +/** + * Help. + * + * @return {string} + */ +function help() { + return [ + '', + 'Usage: ' + command + ' [options] [url]...', + '', + pack.description, + '', + 'Options:', + '', + ' -h, --help output usage information', + ' -v, --version output version number', + '', + 'Usage:', + '', + '# Download file', + '$ ' + command + ' https://github.com/NodeOS/NodeOS/archive/master.zip', + '' + ].join('\n ') + '\n'; +} + +/* + * Program. + */ + +if ( + argv.indexOf('--help') !== -1 || + argv.indexOf('-h') !== -1 +) { + console.log(help()); +} else if ( + argv.indexOf('--version') !== -1 || + argv.indexOf('-v') !== -1 +) { + console.log(pack.version); +} else if (argv.length) { + console.log("Downloading..."); + wget(argv[0], callback); +} else { + console.log(help()); +} +function callback(error, response, body){ + if(error){ + console.log('--- error:'); + console.log(error); + }else{ + console.log('Done!'); + } +} diff --git a/package.json b/package.json index 7158d0c..7c74de9 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,9 @@ "engines": { "node": ">=0.8.6" }, + "bin": { + "wget": "cli.js" + }, "dependencies": { "request": "~2.27.0" }, @@ -38,4 +41,4 @@ "mocha": "~1.12.0", "should": "~1.2.2" } -} \ No newline at end of file +} From f65dce2782bca389b01f6b9773ed1aa9c8eb8e9a Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Wed, 25 Nov 2015 23:03:06 -0500 Subject: [PATCH 2/7] added destination --- README.md | 10 +++++++--- cli.js | 26 ++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 29e4e56..5afe6a4 100644 --- a/README.md +++ b/README.md @@ -69,19 +69,23 @@ $ npm install -g wgetjs Use: ```text -Usage: wget [options] [url]... +Usage: wget [options] Ultra simple async retrieval of remote files over http or https Options: - -h, --help output usage information - -v, --version output version number + -h, --help output usage information + -v, --version output version number + -d, --destination specify download destination Usage: # Download file $ wget https://github.com/NodeOS/NodeOS/archive/master.zip + +# Download file to location +$ wget https://github.com/NodeOS/NodeOS/archive/master.zip -d path/to/here/ ``` ## License: MIT diff --git a/cli.js b/cli.js index 1c212e6..abfbd5f 100644 --- a/cli.js +++ b/cli.js @@ -62,11 +62,24 @@ if ( ) { console.log(pack.version); } else if (argv.length) { - console.log("Downloading..."); - wget(argv[0], callback); + var destinationIndex = argv.indexOf('--destination') + argv.indexOf('-d') + 2; + + var args = {}; + if(destinationIndex){ + args.dest = argv[destinationIndex]; + argv.splice(destinationIndex-1,2); + } + args.url = firstNonFlag(argv); + if(args.url.length > 0){ + console.log("Downloading..."); + wget(args, callback); + }else{ + console.log(help()); + } } else { console.log(help()); } + function callback(error, response, body){ if(error){ console.log('--- error:'); @@ -75,3 +88,12 @@ function callback(error, response, body){ console.log('Done!'); } } + +function firstNonFlag(args){ + for(var i = 0; i < args.length; i++){ + if(args[i].charAt(0) != '-'){ + return args[i]; + } + } + return ""; +} From 190e84b385f9874d26419f5b688f99c6c27c8e66 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Thu, 26 Nov 2015 20:28:29 -0500 Subject: [PATCH 3/7] uploaded --- README.md | 2 +- package.json | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5afe6a4..dd19911 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # wgetjs [![NPM version](https://badge.fury.io/js/wgetjs.png?branch=master)](http://badge.fury.io/js/wgetjs) [![Build Status](https://travis-ci.org/angleman/wgetjs.png?branch=master)](https://travis-ci.org/angleman/wgetjs) [![Dependency Status](https://gemnasium.com/angleman/wgetjs.png?branch=master)](https://gemnasium.com/angleman/wgetjs) [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](#licensemit) -Ultra simple async retrieval of remote files over http or https +Ultra simple async retrieval of remote files over http or https inspired by wgetjs ## Install diff --git a/package.json b/package.json index 7c74de9..3c06019 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "wgetjs", - "version": "0.3.6", + "name": "node-wget", + "version": "0.4.0", "description": "Ultra simple async retrieval of remote files over http or https", "main": "wget.js", "scripts": { @@ -9,7 +9,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/angleman/wgetjs.git" + "url": "https://github.com/tylerl0706/wgetjs.git" }, "keywords": [ "curl", @@ -19,10 +19,10 @@ "http", "https" ], - "author": "angleman", + "author": "tylerl0706", "license": "MIT", "bugs": { - "url": "https://github.com/angleman/wgetjs/issues" + "url": "https://github.com/tylerl0706/wgetjs/issues" }, "engines": { "node": ">=0.8.6" From 0429b4c826a80179f8b89c818def4d3dac045742 Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Sat, 12 Dec 2015 23:48:49 -0500 Subject: [PATCH 4/7] changed wget to node-wget --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dd19911..26ef2de 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ npm install wgetjs ## Usage ```javascript -var wget = require('wgetjs'); +var wget = require('node-wget'); wget(url); @@ -24,7 +24,7 @@ wget({url: url, dry: true}); // dry run, nothing loaded, callback passing parsed ## Examples ```javascript -var wget = require('wgetjs'); +var wget = require('node-wget'); wget('https://raw.github.com/angleman/wgetjs/master/angleman.png'); // angleman.png saved to current folder @@ -63,7 +63,7 @@ wget({ Install: ```bash -$ npm install -g wgetjs +$ npm install -g node-wget ``` Use: From 75669eeb5a651891d034de0df02f5196855df31d Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Sat, 12 Dec 2015 23:49:12 -0500 Subject: [PATCH 5/7] changed wget to node-wget --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 26ef2de..8eff1ea 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Ultra simple async retrieval of remote files over http or https inspired by wget ## Install ``` -npm install wgetjs +npm install node-wget ``` ## Usage From 22ab32d03f92e26da46b4cf40393dd78c4144177 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Mon, 12 Mar 2018 11:59:32 -0400 Subject: [PATCH 6/7] Update all dependencies --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 3c06019..159e551 100644 --- a/package.json +++ b/package.json @@ -31,14 +31,14 @@ "wget": "cli.js" }, "dependencies": { - "request": "~2.27.0" + "request": "~2.85.0" }, "devDependencies": { - "license-md": "~0.2.5", - "grunt": "~0.4.1", - "grunt-bump": "~0.0.11", - "grunt-license": "~0.1.4", - "mocha": "~1.12.0", - "should": "~1.2.2" + "license-md": "~0.3.6", + "grunt": "~1.0.2", + "grunt-bump": "~0.8.0", + "grunt-license": "~0.1.5", + "mocha": "~5.0.4", + "should": "~13.2.1" } } From d3b57102cf4a3711fb41f41eb647b68fc6e297f9 Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Thu, 4 Oct 2018 08:14:22 -0700 Subject: [PATCH 7/7] release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 159e551..55c973b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-wget", - "version": "0.4.0", + "version": "0.4.3", "description": "Ultra simple async retrieval of remote files over http or https", "main": "wget.js", "scripts": {