Clean up oputil help a bit

Minor code tidy + notes
This commit is contained in:
Bryan Ashby 2017-05-22 21:35:06 -06:00
parent d0e2d41c00
commit 1c92b349cd
3 changed files with 48 additions and 41 deletions

View File

@ -234,6 +234,7 @@ function attemptSetEstimatedReleaseDate(fileEntry) {
// //
const maxYear = moment().add(2, 'year').year(); const maxYear = moment().add(2, 'year').year();
const match = getMatch(fileEntry.desc) || getMatch(fileEntry.descLong); const match = getMatch(fileEntry.desc) || getMatch(fileEntry.descLong);
if(match && match[1]) { if(match && match[1]) {
let year; let year;
if(2 === match[1].length) { if(2 === match[1].length) {

View File

@ -185,18 +185,24 @@ function getSpecificFileEntry(pattern, cb) {
const fileEntry = new FileEntry(); const fileEntry = new FileEntry();
fileEntry.load(fileId, () => { fileEntry.load(fileId, () => {
return callback(null, fileEntry); // try sha return callback(null, fileEntry); // try SHA
}); });
}, },
function getBySha(fileEntry, callback) { function getBySha(fileEntry, callback) {
if(fileEntry) { if(fileEntry) {
return callback(null, fileEntry); // already got it by sha return callback(null, fileEntry); // already got it by SHA
} }
FileEntry.findFileBySha(pattern, (err, fileEntry) => { FileEntry.findFileBySha(pattern, (err, fileEntry) => {
return callback(err, fileEntry); return callback(null, fileEntry); // try by PATH
}); });
}, }/*,
function getByPath(fileEntry, callback) {
if(fileEntry) {
return callback(null, fileEntry); // already got by FILE_ID|SHA
}
}
*/
], ],
(err, fileEntry) => { (err, fileEntry) => {
return cb(err, fileEntry); return cb(err, fileEntry);
@ -368,11 +374,10 @@ function moveFiles() {
FileEntry = require('../../core/file_entry.js'); FileEntry = require('../../core/file_entry.js');
async.eachSeries(src, (areaAndStorage, next) => { async.eachSeries(src, (areaAndStorage, next) => {
//
// If this entry represents a area tag, it means *all files* in that area
//
const areaInfo = fileArea.getFileAreaByTag(areaAndStorage.areaTag); const areaInfo = fileArea.getFileAreaByTag(areaAndStorage.areaTag);
if(areaInfo) { if(areaInfo) {
// AREA_TAG[@STORAGE_TAG] - all files in area@tag
src.areaInfo = areaInfo; src.areaInfo = areaInfo;
const findFilter = { const findFilter = {
@ -404,6 +409,7 @@ function moveFiles() {
} else { } else {
// PATH|FILE_ID|SHA|PARTIAL_SHA // PATH|FILE_ID|SHA|PARTIAL_SHA
// :TODO: Implement by FILE|PATH support: find first path|file
getSpecificFileEntry(areaAndStorage.pattern, (err, fileEntry) => { getSpecificFileEntry(areaAndStorage.pattern, (err, fileEntry) => {
if(err) { if(err) {
return next(err); return next(err);

View File

@ -12,60 +12,60 @@ const usageHelp = exports.USAGE_HELP = {
<command> [<args>] <command> [<args>]
global args: global args:
-c, --config PATH : specify config path (${getDefaultConfigPath()}) -c, --config PATH specify config path (${getDefaultConfigPath()})
-n, --no-prompt : assume defaults/don't prompt for input where possible -n, --no-prompt assume defaults/don't prompt for input where possible
where <command> is one of: commands:
user : user utilities user user utilities
config : config file management config config file management
fb : file base management fb file base management
`, `,
User : User :
`usage: optutil.js user --user USERNAME <args> `usage: optutil.js user --user USERNAME <args>
valid args: valid args:
--user USERNAME : specify username for further actions --user USERNAME specify username for further actions
--password PASS : set new password --password PASS set new password
--delete : delete user --delete delete user
--activate : activate user --activate activate user
--deactivate : deactivate user --deactivate deactivate user
`, `,
Config : Config :
`usage: optutil.js config <action> [<args>] `usage: optutil.js config <action> [<args>]
where <action> is one of: actions:
new : generate a new/initial configuration new generate a new/initial configuration
import-areas PATH : import areas using fidonet *.NA or AREAS.BBS file from PATH import-areas PATH import areas using fidonet *.NA or AREAS.BBS file from PATH
valid import-areas <args>: import-areas args:
--conf CONF_TAG : specify conference tag in which to import areas --conf CONF_TAG specify conference tag in which to import areas
--network NETWORK : specify network name/key to associate FTN areas --network NETWORK specify network name/key to associate FTN areas
--uplinks UL1,UL2,... : specify one or more comma separated uplinks --uplinks UL1,UL2,... specify one or more comma separated uplinks
--type TYPE : specifies area import type. valid options are "bbs" and "na" --type TYPE specifies area import type. valid options are "bbs" and "na"
`, `,
FileBase : FileBase :
`usage: oputil.js fb <action> [<args>] <AREA_TAG|SHA|FILE_ID[@STORAGE_TAG] ...> [<args>] `usage: oputil.js fb <action> [<args>] <AREA_TAG|SHA|FILE_ID[@STORAGE_TAG] ...> [<args>]
where <action> is one of: actions:
scan AREA_TAG : scan specified areas scan AREA_TAG scan specified areas
AREA_TAG may be suffixed with @STORAGE_TAG; for example: retro@bbs AREA_TAG may be suffixed with @STORAGE_TAG; for example: retro@bbs
info AREA_TAG|SHA|FILE_ID : display information about areas and/or files info AREA_TAG|SHA|FILE_ID display information about areas and/or files
SHA may be a full or partial SHA-256 SHA may be a full or partial SHA-256
move SRC DST : move entry(s) from SRC to DST where: move SRC DST move entry(s) from SRC to DST where:
SRC may be FILE_ID|SHA|AREA_TAG SRC may be FILE_ID|SHA|AREA_TAG
DST may be AREA_TAG, optionally suffixed with @STORAGE_TAG; for example: retro@bbs DST may be AREA_TAG, optionally suffixed with @STORAGE_TAG; for example: retro@bbs
SHA may be a full or partial SHA-256 SHA may be a full or partial SHA-256
multiple instances of SRC may exist: SRC1 SRC2 ... multiple instances of SRC may exist: SRC1 SRC2 ...
valid scan <args>: scan args:
--tags TAG1,TAG2,... : specify tag(s) to assign to discovered entries --tags TAG1,TAG2,... specify tag(s) to assign to discovered entries
valid info <args>: info args:
--show-desc : display short description, if any --show-desc display short description, if any
` `
}; };