code: def _dataset_line(args):
    
    if args['command'] == 'list':
      filter_ = args['filter'] if args['filter'] else '*'
      context = google.datalab.Context.default()
      if args['project']:
        context = google.datalab.Context(args['project'], context.credentials)
      return _render_list([str(dataset) for dataset in bigquery.Datasets(context)
                           if fnmatch.fnmatch(str(dataset), filter_)])
  
    elif args['command'] == 'create':
      try:
        bigquery.Dataset(args['name']).create(friendly_name=args['friendly'])
      except Exception as e:
        print('Failed to create dataset %s: %s' % (args['name'], e))
  
    elif args['command'] == 'delete':
      try:
        bigquery.Dataset(args['name']).delete()
      except Exception as e:
        print('Failed to delete dataset %s: %s' % (args['name'], e))
docs: Implements the BigQuery dataset magic subcommand used to operate on datasets
  
     The supported syntax is:
     %bq datasets <command> <args>
  
    Commands:
      {list, create, delete}
  
    Args:
      args: the optional arguments following '%bq datasets command'.