code: def sync(args):
      
      import operator
      session = c.Session(args)
      if "all" in args["names"]:
          targetfeeds = session.list_feeds()
      else:
          targetfeeds = []
          for name in args["names"]:
              if name not in session.feeds:
                  print("You don't have a feed called {}."
                        .format(name), file=sys.stderr, flush=True)
              else:
                  targetfeeds.append(name)
      for target in targetfeeds:
          feed = c.Feed(session, target, None)
          if not feed.wentwrong:
              try:
                  title = feed.podcast.target.title
              except AttributeError:
                  title = target
              print("Checking", title, end="...\n")
              currentdate, stop = feed.how_many()
              entrycounter = 0
              entries_to_download = feed.podcast.entries
              for entry in entries_to_download:
                  feed.fix_linkdate(entry)
              # Sort entries_to_download, but only if you want to download as
              # many as there are
              if stop >= len(entries_to_download):
                  entries_to_download.sort(key=operator.attrgetter("linkdate"),
                                           reverse=False)
              for entry in entries_to_download:
                  if entry.linkdate > currentdate:
                      downloaded = feed.download_entry(entry)
                      entrycounter += downloaded
                  if entrycounter >= stop:
                      break
              print("Done")
          else:
              msg = ''.join(["I cannot sync ", feed,
                             " just now. Are you connected to the internet?"])
              print(msg, file=sys.stderr, flush=True)
docs: Implement the 'greg sync' command