This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add size-only flag to cli repo stat command (#3143)
Makes `stats repo` an alias for `repo stat` to make formatting the same across commmands in line with go-ipfs. Also adds `-s` flag to both commands to print just the size info.
- Loading branch information
1 parent
62c1422
commit b4d3bf8
Showing
3 changed files
with
49 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,12 @@ | ||
'use strict' | ||
|
||
const parseDuration = require('parse-duration').default | ||
// This is an alias for `repo stat`. | ||
const repoStats = require('../repo/stat.js') | ||
|
||
module.exports = { | ||
command: 'repo', | ||
...repoStats, | ||
|
||
describe: 'Get stats for the currently used repo', | ||
|
||
builder: { | ||
human: { | ||
type: 'boolean', | ||
default: false | ||
}, | ||
timeout: { | ||
type: 'string', | ||
coerce: parseDuration | ||
} | ||
}, | ||
|
||
async handler ({ ctx: { ipfs, print } }, human, timeout) { | ||
const stats = await ipfs.stats.repo({ human, timeout }) | ||
print(`repo status | ||
number of objects: ${stats.numObjects} | ||
repo size: ${stats.repoSize} | ||
repo path: ${stats.repoPath} | ||
version: ${stats.version} | ||
maximum storage: ${stats.storageMax}`) | ||
} | ||
// The command needs to be renamed, else it would be `stats stat` instead of | ||
// `stats repo` | ||
command: 'repo' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters