github.com/starshine-sys/bcr@v0.21.0/ctx_args.go (about)

     1  package bcr
     2  
     3  // Peek gets the next argument from the context's Args without removing it
     4  func (ctx *Context) Peek() string {
     5  	if len(ctx.InternalArgs) <= ctx.pos {
     6  		return ""
     7  	}
     8  	return ctx.InternalArgs[ctx.pos]
     9  }
    10  
    11  // Pop gets the next argument from the context's Args and removes it from the slice
    12  func (ctx *Context) Pop() string {
    13  	if len(ctx.InternalArgs) <= ctx.pos {
    14  		return ""
    15  	}
    16  	arg := ctx.InternalArgs[ctx.pos]
    17  	ctx.pos++
    18  	ctx.Args = ctx.InternalArgs[ctx.pos:]
    19  	ctx.RawArgs = TrimPrefixesSpace(ctx.RawArgs, arg)
    20  	return arg
    21  }