StevenBlack / hosts

đź”’ Consolidating and extending hosts files from several well-curated sources. Optionally pick extensions for porn, social media, and other categories.
MIT License
26.48k stars 2.2k forks source link

Script not taking command line arguments #1215

Closed pengc99 closed 4 years ago

pengc99 commented 4 years ago

Operating system: Debian 10.3 Python version: Python 3.7.3

Running the script and passing the command line arguments with values of true / false per the readme file results in an error saying the command line arguments were recognized:

root@charlie:/usr/local/src/adblock-hosts# ./updateHostsFile.py --keepdomaincomments false --skipstatichosts "false" --minimise "true" --auto
usage: updateHostsFile.py [-h] [--auto] [--backup]
                          [--extensions [EXTENSIONS [EXTENSIONS ...]]]
                          [--ip TARGETIP] [--keepdomaincomments] [--noupdate]
                          [--skipstatichosts] [--output OUTPUTSUBFOLDER]
                          [--replace] [--flush-dns-cache] [--compress]
                          [--minimise]
updateHostsFile.py: error: unrecognized arguments: false false true
root@charlie:/usr/local/src/adblock-hosts#

However, running them with the arguments without any values works:

root@charlie:/usr/local/src/adblock-hosts# python3 updateHostsFile.py --keepdomaincomments --skipstatichosts --minimise --auto
Updating source data/adaway.org from https://raw.githubusercontent.com/AdAway/adaway.github.io/master/hosts.txt
Updating source data/UncheckyAds from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/UncheckyAds/hosts
Updating source data/mvps.org from http://winhelp2002.mvps.org/hosts.txt
Updating source data/URLHaus from https://urlhaus.abuse.ch/downloads/hostfile/
Updating source data/Badd-Boyz-Hosts from https://raw.githubusercontent.com/mitchellkrogza/Badd-Boyz-Hosts/master/hosts
Updating source data/StevenBlack from https://raw.githubusercontent.com/StevenBlack/hosts/master/data/StevenBlack/hosts
Updating source data/KADhosts from https://raw.githubusercontent.com/PolishFiltersTeam/KADhosts/master/KADhosts_without_controversies.txt
Updating source data/add.Risk from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Risk/hosts
Updating source data/tiuxo from https://raw.githubusercontent.com/tiuxo/hosts/master/ads
Updating source data/hostsVN from https://raw.githubusercontent.com/bigdargon/hostsVN/master/option/hosts-VN
Updating source data/yoyo.org from https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext&useip=0.0.0.0
Updating source data/add.Spam from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Spam/hosts
Updating source data/add.Dead from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Dead/hosts
Updating source data/malwaredomainlist.com from https://www.malwaredomainlist.com/hostslist/hosts.txt
Updating source data/someonewhocares.org from https://someonewhocares.org/hosts/zero/hosts
Updating source data/add.2o7Net from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.2o7Net/hosts
Updating source extensions/porn/clefspeare13 from https://raw.githubusercontent.com/Clefspeare13/pornhosts/master/0.0.0.0/hosts
Updating source extensions/porn/sinfonietta from https://raw.githubusercontent.com/Sinfonietta/hostfiles/master/pornography-hosts
Updating source extensions/porn/tiuxo from https://raw.githubusercontent.com/tiuxo/hosts/master/porn
Updating source extensions/porn/sinfonietta-snuff from https://raw.githubusercontent.com/Sinfonietta/hostfiles/master/snuff-hosts
Updating source extensions/gambling from https://raw.githubusercontent.com/Sinfonietta/hostfiles/master/gambling-hosts
Updating source extensions/social/sinfonietta from https://raw.githubusercontent.com/Sinfonietta/hostfiles/master/social-hosts
Updating source extensions/social/tiuxo from https://raw.githubusercontent.com/tiuxo/hosts/master/social
Updating source extensions/fakenews from https://raw.githubusercontent.com/marktron/fakenews/master/fakenews
==>fe00::0 ip6-localnet<==
==>ff00::0 ip6-mcastprefix<==
==>ff02::2 ip6-allrouters<==
==>ff02::3 ip6-allhosts<==
Success! The hosts file has been saved in folder
It contains 54,507 unique entries.
root@charlie:/usr/local/src/adblock-hosts#

Am I somehow using the script wrong or reading the readme file wrong? I know running it as root is bad juju but this is just a test environment.

welcome[bot] commented 4 years ago

Hello! Thank you for opening your first issue in this repo. It’s people like you who make these host files better!

StevenBlack commented 4 years ago

Hi Andrew @pengc99

In your example, --keepdomaincomments, --skipstatichosts --minimise are flags. Flags are either set, or not. You don't pass arguments or options to flags.

I agree, this distinction could be clearer in the help text.

Here's the code where flags and options are parsed.

pengc99 commented 4 years ago

I understand, thanks for clarifying. I'll submit a pull request to help clear up the wording on the flags.