
from __future__ import print_function
import json
import click
from wensleydale import parser


@click.command()
@click.argument('path', type=str)
@click.argument('query', type=str)
@click.version_option()
def main(path, query, level=None, version=None):
    '''
    Mr Wensleydale. Query the AST using ObjectPath and return JSON.
    '''
    # Run the query.
    result = parser.run(path, query)

    # Spit out the result.
    print(json.dumps(result))


from __future__ import print_function
import json
import click
from wensleydale import parser


@click.command()
@click.argument('path', type=click.Path(exists=True))
@click.argument('query', type=str)
@click.version_option()
def main(path, query, level=None, version=None):
    '''
    Mr Wensleydale. Query the AST using ObjectPath and return JSON.
    '''
    # Run the query.
    result = parser.run(path, query)

    # Spit out the result.
    print(json.dumps(result))

Add file path existince checking
Add file path existince checking

  
  from __future__ import print_function
  import json
  import click
  from wensleydale import parser
  
  
  @click.command()
- @click.argument('path', type=str)
+ @click.argument('path', type=click.Path(exists=True))
  @click.argument('query', type=str)
  @click.version_option()
  def main(path, query, level=None, version=None):
      '''
      Mr Wensleydale. Query the AST using ObjectPath and return JSON.
      '''
      # Run the query.
      result = parser.run(path, query)
  
      # Spit out the result.
      print(json.dumps(result))
  
Add file path existince checking
## Code Before:

from __future__ import print_function
import json
import click
from wensleydale import parser


@click.command()
@click.argument('path', type=str)
@click.argument('query', type=str)
@click.version_option()
def main(path, query, level=None, version=None):
    '''
    Mr Wensleydale. Query the AST using ObjectPath and return JSON.
    '''
    # Run the query.
    result = parser.run(path, query)

    # Spit out the result.
    print(json.dumps(result))

## Instruction:
Add file path existince checking
## Code After:

from __future__ import print_function
import json
import click
from wensleydale import parser


@click.command()
@click.argument('path', type=click.Path(exists=True))
@click.argument('query', type=str)
@click.version_option()
def main(path, query, level=None, version=None):
    '''
    Mr Wensleydale. Query the AST using ObjectPath and return JSON.
    '''
    # Run the query.
    result = parser.run(path, query)

    # Spit out the result.
    print(json.dumps(result))
