Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added pattern matching to the cli utility

  • Loading branch information...
commit 695a32183b72f83ad47302bae56e637882d26e56 1 parent 9180384
@bermi authored
View
7 HISTORY.md
@@ -1,4 +1,9 @@
-0.0.2 / 2011-04-24
+0.1.1 / 2011-10-07
+==================
+
+ * Added command line utility
+
+0.0.2 / 2011-10-05
==================
* Updated package.json
View
23 README.md
@@ -17,21 +17,40 @@ Displays this help
Generates a memorable password
Options:
- -l Password length
+ -l Password length
-c Generates a non memorable password [default: false]
- -h Displays this help
+ -p Pattern to match for the generated password
+ -h Displays this help
Simple memorable pass
password-generator
+ => maqetaxaku
Custom length
password-generator -l 30
+ => nugiferagiraqadamedewubaqirali
Non memorable
password-generator -c
+ => QPnb3gl7_0
+
+Customize the pattern to match for each password character
+
+ password-generator -p "[\d\W\w\p]"
+ => Je;VgG?{Yd
+
+Any number or letter
+
+ password-generator -p "[\w]"
+ => 3NHPqzjIAq
+
+Combine multiple strategies 6 memorable and 3 numbers
+
+ echo "`password-generator -l 6``password-generator -p "[0-9]" -l 3`"
+ => wazawe351
### From node.js
View
12 lib/cli.js
@@ -14,15 +14,23 @@ argv = optimist.usage('Generates a memorable password', {
description: 'Generates a non memorable password',
"default": 'memorable'
},
+ p: {
+ description: 'Pattern to match for the generated password'
+ },
h: {
description: 'Displays this help'
}
}).argv;
this.run = function() {
- var generatePassword = require('./password-generator');
+ var generatePassword = require('./password-generator'),
+ pattern = argv.p || null;
if (argv.h) {
return optimist.showHelp();
}
- puts(generatePassword(argv.l, argv.c === 'memorable'));
+ if(pattern){
+ pattern = new RegExp(pattern);
+ argv.c = false;
+ }
+ puts(generatePassword(argv.l, argv.c === 'memorable', pattern));
};
View
2  lib/password-generator.js
@@ -46,4 +46,4 @@ module.exports = password = function(length, memorable, pattern, prefix) {
/**
* Version.
*/
-exports.version = '0.1.0';
+exports.version = '0.1.2';
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "password-generator",
- "version": "0.1.0",
+ "version": "0.1.2",
"description": "Memorable password generator",
"author": "Bermi Ferrer <bermi@bermilabs.com>",
"keywords": ["password", "generator", "pass", "random"],
Please sign in to comment.
Something went wrong with that request. Please try again.