mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-08-03 16:31:59 +02:00
Add oputil fb desc
This commit is contained in:
parent
f4088303ca
commit
c6e176f5bd
5 changed files with 113 additions and 18 deletions
|
@ -413,11 +413,11 @@ function dumpFileInfo(shaOrFileId, cb) {
|
|||
);
|
||||
}
|
||||
|
||||
function displayFileAreaInfo() {
|
||||
function displayFileOrAreaInfo() {
|
||||
// AREA_TAG[@STORAGE_TAG]
|
||||
// SHA256|PARTIAL
|
||||
// SHA256|PARTIAL|FILE_ID|FILENAME_WILDCARD
|
||||
// if sha: dump file info
|
||||
// if area/stoarge dump area(s) +
|
||||
// if area/storage dump area(s) +
|
||||
|
||||
async.series(
|
||||
[
|
||||
|
@ -908,6 +908,75 @@ function importFileAreas() {
|
|||
);
|
||||
}
|
||||
|
||||
function setFileDescription() {
|
||||
//
|
||||
// ./oputil.js fb set-desc CRITERIA # will prompt
|
||||
// ./oputil.js fb set-desc CRITERIA "The new description"
|
||||
//
|
||||
let fileCriteria;
|
||||
let desc;
|
||||
if(argv._.length > 3) {
|
||||
fileCriteria = argv._[argv._.length - 2];
|
||||
desc = argv._[argv._.length - 1];
|
||||
} else {
|
||||
fileCriteria = argv._[argv._.length - 1];
|
||||
}
|
||||
|
||||
async.waterfall(
|
||||
[
|
||||
(callback) => {
|
||||
return initConfigAndDatabases(callback);
|
||||
},
|
||||
(callback) => {
|
||||
getFileEntries(fileCriteria, (err, entries) => {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if(entries.length > 1) {
|
||||
return callback(Errors.General('Criteria not specific enough.'));
|
||||
}
|
||||
|
||||
return callback(null, entries[0]);
|
||||
});
|
||||
},
|
||||
(fileEntry, callback) => {
|
||||
if(desc) {
|
||||
return callback(null, fileEntry, desc);
|
||||
}
|
||||
|
||||
getAnswers([
|
||||
{
|
||||
name : 'userDesc',
|
||||
message : 'Description:',
|
||||
type : 'editor',
|
||||
}
|
||||
],
|
||||
answers => {
|
||||
if(!answers.userDesc) {
|
||||
return callback(Errors.General('User canceled'));
|
||||
}
|
||||
return callback(null, fileEntry, answers.userDesc);
|
||||
});
|
||||
},
|
||||
(fileEntry, newDesc, callback) => {
|
||||
fileEntry.desc = newDesc;
|
||||
fileEntry.persist(true, err => { // true=isUpdate
|
||||
return callback(err);
|
||||
});
|
||||
}
|
||||
],
|
||||
err => {
|
||||
if(err) {
|
||||
process.exitCode = ExitCodes.ERROR;
|
||||
console.error(err.message);
|
||||
} else {
|
||||
console.info('Description updated.');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function handleFileBaseCommand() {
|
||||
|
||||
function errUsage() {
|
||||
|
@ -924,7 +993,7 @@ function handleFileBaseCommand() {
|
|||
const action = argv._[1];
|
||||
|
||||
return ({
|
||||
info : displayFileAreaInfo,
|
||||
info : displayFileOrAreaInfo,
|
||||
scan : scanFileAreas,
|
||||
|
||||
mv : moveFiles,
|
||||
|
@ -936,5 +1005,8 @@ function handleFileBaseCommand() {
|
|||
delete : removeFiles,
|
||||
|
||||
'import-areas' : importFileAreas,
|
||||
|
||||
desc : setFileDescription,
|
||||
description : setFileDescription,
|
||||
}[action] || errUsage)();
|
||||
}
|
|
@ -57,9 +57,7 @@ actions:
|
|||
for example: scan some_area *.zip
|
||||
|
||||
info CRITERIA display information about areas and/or files
|
||||
where CRITERIA is one of the following:
|
||||
AREA_TAG|SHA|FILE_ID|FILENAME_WC
|
||||
SHA may be a full or partial SHA-256
|
||||
matching CRITERIA.
|
||||
|
||||
mv SRC [SRC...] DST move entry(s) from SRC to DST
|
||||
SRC: FILENAME_WC|SHA|FILE_ID|AREA_TAG[@STORAGE_TAG]
|
||||
|
@ -67,6 +65,9 @@ actions:
|
|||
|
||||
rm SRC [SRC...] remove entry(s) from the system matching SRC
|
||||
SRC: FILENAME_WC|SHA|FILE_ID|AREA_TAG[@STORAGE_TAG]
|
||||
desc CRITERIA sets a new file description for file base entry
|
||||
matching CRITERIA. Launches an external editor using
|
||||
$VISUAL, $EDITOR, or vim/notepad.
|
||||
import-areas FILEGATE.ZXX import file base areas using FileGate RAID type format
|
||||
|
||||
scan args:
|
||||
|
@ -93,6 +94,9 @@ import-areas args:
|
|||
general information:
|
||||
AREA_TAG[@STORAGE_TAG] can specify an area tag and optionally, a storage specific tag
|
||||
example: retro@bbs
|
||||
|
||||
CRITERIA file base entry criteria. in general, can be AREA_TAG, SHA,
|
||||
FILE_ID, or FILENAME_WC.
|
||||
|
||||
FILENAME_WC filename with * and ? wildcard support. may match 0:n entries
|
||||
SHA full or partial SHA-256
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue