Add a simple command to generate a bunch of random posts ()

* 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:
Whyrusleeping 2022-04-13 11:05:35 -07:00 committed by GitHub
parent 53847a1a83
commit 96a96f43c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 0 deletions

@ -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++) {