#!/usr/bin/env python
# vim: set filetype=python

# Copyright 2015 Lionheart Software LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse

from twitter_cleanse.cleanse import cleanse

if __name__ == "__main__":
    parser = argparse.ArgumentParser(prog="twitter-cleanse")
    parser.add_argument("--consumer-key", "--consumer_key", help="Your Twitter application's consumer key.")
    parser.add_argument("--consumer-secret", "--consumer_secret", help="Your Twitter application's consumer secret.")
    parser.add_argument("--access-token", "--access_token", help="Your Twitter access token.")
    parser.add_argument("--access-token-secret", "--access_token_secret", help="Your Twitter access token secret.")
    parser.add_argument("--use-cache", type=bool, default=True, help="Use a file cache to cache Twitter response payloads (defaults to true).")
    parser.add_argument("--years-dormant-threshold", "--years", type=float, default=2, help="The number of years a person hasn't tweeted for to be unfollowed (defaults to 2).")
    parser.add_argument("--dry-run", type=bool, default=False, help="Print out log messages as usual, but don't actually unfollow anyone.")

    args = parser.parse_args()
    if all([args.access_token, args.access_token_secret, args.consumer_key, args.consumer_secret]):
        cleanse(args.consumer_key, args.consumer_secret, args.access_token, args.access_token_secret, args.use_cache, args.years_dormant_threshold, args.dry_run)
    else:
        parser.print_help()
