mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2024-12-22 16:26:25 +00:00
added command to display some info about the config file
This commit is contained in:
parent
ad5afab355
commit
b40adcae1f
@ -8,6 +8,7 @@ import { config, INSTALL_DIR, VERSION } from './autorestic'
|
|||||||
import { checkAndConfigureBackends, getBackendsFromLocations, getEnvFromBackend } from './backend'
|
import { checkAndConfigureBackends, getBackendsFromLocations, getEnvFromBackend } from './backend'
|
||||||
import { backupAll } from './backup'
|
import { backupAll } from './backup'
|
||||||
import { forgetAll } from './forget'
|
import { forgetAll } from './forget'
|
||||||
|
import showAll from './info'
|
||||||
import { Backends, Flags, Locations } from './types'
|
import { Backends, Flags, Locations } from './types'
|
||||||
import {
|
import {
|
||||||
checkIfCommandIsAvailable,
|
checkIfCommandIsAvailable,
|
||||||
@ -138,6 +139,9 @@ const handlers: Handlers = {
|
|||||||
console.log(out, err)
|
console.log(out, err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async info() {
|
||||||
|
showAll()
|
||||||
|
},
|
||||||
async install() {
|
async install() {
|
||||||
try {
|
try {
|
||||||
checkIfResticIsAvailable()
|
checkIfResticIsAvailable()
|
||||||
@ -240,6 +244,7 @@ export const help = () => {
|
|||||||
`\n -c, --config Specify config file. Default: .autorestic.yml` +
|
`\n -c, --config Specify config file. Default: .autorestic.yml` +
|
||||||
'\n' +
|
'\n' +
|
||||||
'\nCommands:'.yellow +
|
'\nCommands:'.yellow +
|
||||||
|
'\n info Show all locations and backends' +
|
||||||
'\n check [-b, --backend] [-a, --all] Check backends' +
|
'\n check [-b, --backend] [-a, --all] Check backends' +
|
||||||
'\n backup [-l, --location] [-a, --all] Backup all or specified locations' +
|
'\n backup [-l, --location] [-a, --all] Backup all or specified locations' +
|
||||||
'\n forget [-l, --location] [-a, --all] [--dry-run] Forget old snapshots according to declared policies' +
|
'\n forget [-l, --location] [-a, --all] [--dry-run] Forget old snapshots according to declared policies' +
|
||||||
|
28
src/info.ts
Normal file
28
src/info.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { config } from './autorestic'
|
||||||
|
import { ConfigError, fill, treeToString } from './utils'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const showAll = () => {
|
||||||
|
if (!config) throw ConfigError
|
||||||
|
|
||||||
|
console.log('\n\n' + fill(32, '_') + 'LOCATIONS:'.underline)
|
||||||
|
for (const [key, data] of Object.entries(config.locations)) {
|
||||||
|
console.log(`\n${key.blue.underline}:`)
|
||||||
|
console.log(treeToString(
|
||||||
|
data,
|
||||||
|
['to:', 'from:', 'hooks:', 'options:'],
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('\n\n' + fill(32, '_') + 'BACKENDS:'.underline)
|
||||||
|
for (const [key, data] of Object.entries(config.backends)) {
|
||||||
|
console.log(`\n${key.blue.underline}:`)
|
||||||
|
console.log(treeToString(
|
||||||
|
data,
|
||||||
|
['type:', 'path:', 'key:'],
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default showAll
|
Loading…
Reference in New Issue
Block a user