import { Command , flags } from "@oclif/command" ; import * as service from "../service/post" ; export default class Post extends Command { static description = "Post to a channel" ; static flags = { help : flags . help ( { char : "h" } ) , channel : flags . string ( { char : "c" , description : "Channel address" , required : true , } ) , "from-stdin" : flags . boolean ( { char : "i" } ) , } ; static args = [ { name : "message" } ] ; async run ( ) { const { args , flags } = this . parse ( Post ) ; if ( flags [ "from-stdin" ] ) { process . stdin . on ( "data" , async ( data ) => { await service . post ( data , flags . channel ) ; } ) ; } else { await service . post ( args . message , flags . channel ) ; } } }