mirror of https://git.envs.net/envs/twtxt.git
Ask user for twturl in twtxt quickstart (closes #116)
This commit is contained in:
parent
99a17dd236
commit
b6f54aa519
|
@ -12,17 +12,21 @@ Use twtxt's **quickstart** command to bootstrap a default configuration:
|
|||
twtxt - quickstart
|
||||
==================
|
||||
|
||||
This wizard will generate a basic configuration file for twtxt
|
||||
with all mandatory options set. Have a look at the docs to
|
||||
get information about the other available options and their meaning.
|
||||
This wizard will generate a basic configuration file for twtxt with all
|
||||
mandatory options set. You can change all of these later with either twtxt
|
||||
itself or by editing the config file manually. Have a look at the docs to get
|
||||
information about the other available options and their meaning.
|
||||
|
||||
|
||||
➤ Please enter your desired nick [$USER]: <NICKNAME>
|
||||
➤ Please enter the desired location for your config
|
||||
file [~/.config/twtxt/config]: <CONFIG FILE LOCATION>
|
||||
➤ Please enter the desired location for your twtxt
|
||||
file [~/twtxt.txt]: <TWTXTX FILE LOCATION>
|
||||
➤ Please enter the URL your twtxt file will be accessible
|
||||
from [https://example.org/twtxt.txt]: <TWTXT URL>
|
||||
➤ Do you want to disclose your identity?
|
||||
Your nick and URL will be shared [y/N]: y
|
||||
Your nick and URL will be shared when making HTTP requests [y/N]: y
|
||||
|
||||
➤ Do you want to follow the twtxt news feed? [Y/n]: y
|
||||
|
||||
|
@ -31,11 +35,12 @@ Use twtxt's **quickstart** command to bootstrap a default configuration:
|
|||
|
||||
The quickstart wizard prompts for the following configuration values:
|
||||
|
||||
- Your desired nick name (*<NICKNAME>*)
|
||||
- Your desired nick name, doesn’t need to be unique (*<NICKNAME>*)
|
||||
- The desired location for your config file (*<CONFIG FILE LOCATION>*)
|
||||
- The desired location for your twtxt file (*<TWTXTX FILE LOCATION>*)
|
||||
- The URL your twtxt file will be accessible from remotely (*<TWTXT URL>*)
|
||||
- If you want to disclose your identity. If True your nick and URL will be used in the User-Agent
|
||||
attribute when fetching other twtxt files.
|
||||
header attribute when fetching other twtxt files via HTTP.
|
||||
- If you want to follow the official twtxt news feed
|
||||
|
||||
The configurations can easily be changed in the twtxt configuration file. See :ref:`configuration`.
|
||||
|
|
|
@ -122,15 +122,18 @@ def test_discover():
|
|||
def test_create_config(config_dir):
|
||||
config_dir_old = Config.config_dir
|
||||
Config.config_dir = str(config_dir.join("new"))
|
||||
conf_w = Config.create_config(os.path.join(Config.config_dir, Config.config_name), "bar", "batz.txt", False, True)
|
||||
conf_w = Config.create_config(os.path.join(Config.config_dir, Config.config_name),
|
||||
"bar", "batz.txt", "https://example.org", False, True)
|
||||
conf_r = Config.discover()
|
||||
assert conf_r.nick == "bar"
|
||||
assert conf_r.twtfile == "batz.txt"
|
||||
assert conf_r.twturl == "https://example.org"
|
||||
assert conf_r.character_limit == 140
|
||||
assert conf_r.character_warning == 140
|
||||
assert conf_r.following[0].nick == "twtxt"
|
||||
assert conf_r.following[0].url == "https://buckket.org/twtxt_news.txt"
|
||||
assert set(conf_r.options.keys()) == {"nick", "twtfile", "disclose_identity", "character_limit", "character_warning"}
|
||||
assert set(conf_r.options.keys()) == {"nick", "twtfile", "twturl", "disclose_identity", "character_limit",
|
||||
"character_warning"}
|
||||
|
||||
conf_r.cfg.remove_section("twtxt")
|
||||
assert conf_r.options == {}
|
||||
|
|
10
twtxt/cli.py
10
twtxt/cli.py
|
@ -281,6 +281,7 @@ def quickstart():
|
|||
click.echo()
|
||||
|
||||
help_text = "This wizard will generate a basic configuration file for twtxt with all mandatory options set. " \
|
||||
"You can change all of these later with either twtxt itself or by editing the config file manually. " \
|
||||
"Have a look at the docs to get information about the other available options and their meaning."
|
||||
click.echo(textwrap.fill(help_text, width))
|
||||
|
||||
|
@ -303,13 +304,16 @@ def quickstart():
|
|||
twtfile = os.path.expanduser(twtfile)
|
||||
overwrite_check(twtfile)
|
||||
|
||||
disclose_identity = click.confirm("➤ Do you want to disclose your identity? Your nick and URL will be shared",
|
||||
default=False)
|
||||
twturl = click.prompt("➤ Please enter the URL your twtxt file will be accessible from",
|
||||
default="https://example.org/twtxt.txt")
|
||||
|
||||
disclose_identity = click.confirm("➤ Do you want to disclose your identity? Your nick and URL will be shared when "
|
||||
"making HTTP requests", default=False)
|
||||
|
||||
click.echo()
|
||||
add_news = click.confirm("➤ Do you want to follow the twtxt news feed?", default=True)
|
||||
|
||||
conf = Config.create_config(cfgfile, nick, twtfile, disclose_identity, add_news)
|
||||
conf = Config.create_config(cfgfile, nick, twtfile, twturl, disclose_identity, add_news)
|
||||
|
||||
twtfile_dir = os.path.dirname(twtfile)
|
||||
if not os.path.exists(twtfile_dir):
|
||||
|
|
|
@ -60,12 +60,13 @@ class Config:
|
|||
return cls.from_file(file)
|
||||
|
||||
@classmethod
|
||||
def create_config(cls, cfgfile, nick, twtfile, disclose_identity, add_news):
|
||||
def create_config(cls, cfgfile, nick, twtfile, twturl, disclose_identity, add_news):
|
||||
"""Create a new config file at the default location.
|
||||
|
||||
:param str cfgfile: path to the config file
|
||||
:param str nick: nickname to use for own tweets
|
||||
:param str twtfile: path to the local twtxt file
|
||||
:param str twturl: URL to the remote twtxt file
|
||||
:param bool disclose_identity: if true the users id will be disclosed
|
||||
:param bool add_news: if true follow twtxt news feed
|
||||
"""
|
||||
|
@ -78,6 +79,7 @@ class Config:
|
|||
cfg.add_section("twtxt")
|
||||
cfg.set("twtxt", "nick", nick)
|
||||
cfg.set("twtxt", "twtfile", twtfile)
|
||||
cfg.set("twtxt", "twturl", twturl)
|
||||
cfg.set("twtxt", "disclose_identity", str(disclose_identity))
|
||||
cfg.set("twtxt", "character_limit", "140")
|
||||
cfg.set("twtxt", "character_warning", "140")
|
||||
|
|
Loading…
Reference in New Issue