Skip to content

Commit

Permalink
Merge pull request #325 from Syncano/feat/cli-backups
Browse files Browse the repository at this point in the history
Cli backups
  • Loading branch information
jonny22094 committed Nov 17, 2018
2 parents ca69086 + fbae5d7 commit 2efe58d
Show file tree
Hide file tree
Showing 11 changed files with 557 additions and 19 deletions.
17 changes: 17 additions & 0 deletions docs/cheatsheet/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,23 @@ <h4>Synchronize files of given hosting</h4>
<h4>Configure hosting options</h4>
<pre><code class="lang-bash">npx s hosting config &lt;hosting name&gt; --cname &lt;domain name&gt;
s hosting config &lt;hosting name&gt; --remove-cname &lt;domain name&gt;</code></pre>

<h3>Backups</h3>

<h4>Create new backup</h4>
<pre><code class="lang-bash">npx s backups create</code></pre>

<h4>Delete backup</h4>
<pre><code class="lang-bash">npx s backups delete &lt;id&gt;</code></pre>

<h4>Delete all backups</h4>
<pre><code class="lang-bash">npx s backups delete all</code></pre>

<h4>Backups list</h4>
<pre><code class="lang-bash">npx s backups list</code></pre>

<h4>Last backup</h4>
<pre><code class="lang-bash">npx s backups last</code></pre>
</section>
<!--
Expand Down
196 changes: 191 additions & 5 deletions packages/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions packages/cli/src/cli-backups.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env node
import program from './program'
import commands from './commands'
import session from './utils/session'
import context from './utils/context'
import { echo } from './utils/print-tools'

const setup = async () => {
await context.session.load()

program
.command('create')
.group('Backups')
.description('Create backup')
.action(async (...options) => {
session.isAuthenticated()
session.hasProject()
await session.checkConnection()
echo()
new commands.BackupsCreate(context).run(options)
})

program
.command('list')
.group('Backups')
.description('List backups')
.action(async (...options) => {
session.isAuthenticated()
session.hasProject()
await session.checkConnection()
echo()
new commands.BackupsList(context).run(options)
})

program
.command('last')
.group('Backups')
.description('Last backup')
.action(async (...options) => {
session.isAuthenticated()
session.hasProject()
await session.checkConnection()
echo()
new commands.BackupsLast(context).run(options)
})

program
.command('delete <id>')
.group('Backups')
.option('all', 'Delete all backups')
.description('Delete backup')
.action(async (...options) => {
session.isAuthenticated()
session.hasProject()
await session.checkConnection()
echo()
new commands.BackupsDelete(context).run(options)
})

if (!process.argv.slice(2).length) {
program.outputHelp()
}

program.parse(process.argv)
}

setup()
4 changes: 4 additions & 0 deletions packages/cli/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ const setup = async () => {
new commands.SocketTrace(context).run(options)
})

program
.command('backups', 'Menage your backups')
.on('*', (commandsArr) => validateCommands(commandsArr))

program
.command('hosting', 'Manage your web assets and host them on Syncano')
.on('*', (commandsArr) => validateCommands(commandsArr))
Expand Down
Loading

0 comments on commit 2efe58d

Please sign in to comment.