Skip to content

Commit

Permalink
modify: mv cli messages under if(import...) condition
Browse files Browse the repository at this point in the history
  • Loading branch information
phette23 committed Sep 11, 2023
1 parent 5f37107 commit 4795053
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions utilities/metadata-csv/modify.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,6 @@ import { default as CSVReader } from 'csv-reader'

let options = rc('metadata-csv', { 'root': 'https://vault.cca.edu/api' })

// usage info
if (options.h || options.help) {
console.log('Usage:\n\tnode modify --csv input.csv [--debug] [--dryrun]\n')
console.log('Modify records based on a CSV of metadata. The CSV must have a header row, the first column must be the item UUID, and the second column must be the item version. The rest are treaded as metadata columns where the header is the XPath of the field to be modified (e.g. "/xml/mods/abstract"). It is recommended to use full paths that start with "/xml/mods".')
console.log('\nOptions:')
console.log('\t--csv:'.padEnd(12) + 'metadata changes spreadsheet')
console.log('\t--debug:'.padEnd(12) + 'prints a lot more information about what\'s going on')
console.log('\t--dryrun:'.padEnd(12) + 'do not modify records, but print XML documents')
process.exit(0)
}

if (options.dryrun) console.log('Dry run: no records will be modified.')

const headers = {
'X-Authorization': 'access_token=' + options.token,
'Accept': 'application/json',
Expand Down Expand Up @@ -207,5 +194,17 @@ const main = () => {
export { checkPathPrefixes, insertNewElement, prepChanges, makeChangesHash }

if (import.meta.url.replace(/\.js$/, '') === pathToFileURL(process.argv[1]).href.replace(/\.js$/, '')) {
// usage info
if (options.h || options.help) {
console.log('Usage:\n\tnode modify --csv input.csv [--debug] [--dryrun]\n')
console.log('Modify records based on a CSV of metadata. The CSV must have a header row, the first column must be the item UUID, and the second column must be the item version. The rest are treaded as metadata columns where the header is the XPath of the field to be modified (e.g. "/xml/mods/abstract"). It is recommended to use full paths that start with "/xml/mods".')
console.log('\nOptions:')
console.log('\t--csv:'.padEnd(12) + 'metadata changes spreadsheet')
console.log('\t--debug:'.padEnd(12) + 'prints a lot more information about what\'s going on')
console.log('\t--dryrun:'.padEnd(12) + 'do not modify records, but print XML documents')
process.exit(0)
}

if (options.dryrun) console.log('Dry run: no records will be modified.')
main()
}

0 comments on commit 4795053

Please sign in to comment.