Add a simple command to generate a bunch of random posts (#73)
* add a simple command to generate a bunch of random posts * move spam command into its own subcommand grouping: * learn how the typescript build system works
This commit is contained in:
parent
53847a1a83
commit
96a96f43c1
cli/src
31
cli/src/commands/dev/spam.ts
Normal file
31
cli/src/commands/dev/spam.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import cmd from '../../lib/command.js'
|
||||
import { loadDelegate } from '../../lib/client.js'
|
||||
import { REPO_PATH } from '../../lib/env.js'
|
||||
import { TID } from '@bluesky/common'
|
||||
|
||||
function makeRandText(l: number) {
|
||||
var set = ' abcdefghijklmnopqrstuvwxyz ';
|
||||
var len = set.length;
|
||||
var out = '';
|
||||
for ( let i = 0; i < len; i++ ) {
|
||||
out += set.charAt(Math.floor(Math.random() *
|
||||
len));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
export default cmd({
|
||||
name: 'gen-random-posts',
|
||||
category: 'dev',
|
||||
help: 'Create a large number of random posts.',
|
||||
args: [{ name: 'count' }],
|
||||
async command(args) {
|
||||
const count : number = +(args._[0])
|
||||
const client = await loadDelegate(REPO_PATH)
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
await client.addPost(makeRandText(100))
|
||||
}
|
||||
|
||||
},
|
||||
})
|
@ -17,3 +17,4 @@ import './social/list-followers.js'
|
||||
import './social/unfollow.js'
|
||||
import './social/whoami.js'
|
||||
import './social/whois.js'
|
||||
import './dev/spam.js'
|
||||
|
@ -15,6 +15,7 @@ export const CATEGORIES = {
|
||||
posts: 'Posts',
|
||||
interactions: 'Interactions',
|
||||
advanced: 'Advanced',
|
||||
dev: 'Development',
|
||||
}
|
||||
|
||||
export interface Cmd {
|
||||
|
@ -37,6 +37,7 @@ export function usage(err: any) {
|
||||
addcat('posts')
|
||||
addcat('interactions')
|
||||
addcat('advanced')
|
||||
addcat('dev')
|
||||
for (const cat of cats) {
|
||||
console.log(`\n${chalk.bold(cat.label)}:\n`)
|
||||
for (let i = 0; i < cat.lhs.length; i++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user