CLI tool to get function name from line of source code

You should be able to use ast-grep for this.