Comments (20)
I'd like to postpone creating more config wizards until there's proper support from vdirsyncer to discover configured calendars. Khal probes the non-public API of vdirsyncer for this, which is nasty.
from todoman.
Hello @zebak12, glad to hear that!
we would have to call a function
Instead of directly launching the configuration wizard if no config exists, I would prefer it if we create a new command in cli.py
(todo configure
). In the "config not found" error message we can then tell people to run that command.
(For ex: I didin't define TODOMAN_CONFIG and therefore, it used XDG_CONFIG_DIRS by default, hence I had to use sudo while writing the configuration file)
I don't think it's justified. XDG_CONFIG_DIR
should be within your homefolder, and you should have write permissions for that. Something else is wrong if you have to use sudo
. Where did you create the config file in the end?
from todoman.
To compliment a bit what @untitaker said:
- I'd change the messages here and here to hint users that they can run
todo configure
. - Following on your exact scenario, we could also have
todo configure --location
, that prints an exists:- The path of an existing file is one was found.
- The path to the default configuration file if none exists (relative to
xdg.BaseDirectory.xdg_config_dirs[0]
.
- Yes,
configure
should be a separate command.
Regarding your sudo
issue, can you run:
python -c "import xdg.BaseDirectory; print(xdg.BaseDirectory.xdg_config_dirs)"
The first of these two is the one you should use (the second will be read if none is present, but is system-wide instead of user-wide, and not recommended).
from todoman.
Regarding your sudo issue, can you run:
python -c "import xdg.BaseDirectory; print(xdg.BaseDirectory.xdg_config_dirs)"
Oh! Just got that 🎉
Thanks :)
from todoman.
I'd rather have interactive questions (instead of cli flags) for configure.
Something like:
> What is the name of you default list?
[wait for user input here]
etc. I think this is a it quite unlike the rest of what we have implemented already and more wizard-like.
from todoman.
BTW, prompting can be done with http://click.pocoo.org/6/prompts/#input-prompts
from todoman.
Actually, my intention was for users to provide the exact value that ends up in the config file, not do some super-smart discovery.
from todoman.
I see, I suppose that doesn't have to be postponed.
from todoman.
Hello, I am new and would like to work on this one!
According to what I interpret, changes ought to be made here in a manner such that when the configuration file is missing, instead of raising a ConfigurationException
, we would have to call a function which would indeed ask for input and then would write those preferences to the custom_path
or XDG_CONFIG_DIRS
as would have been chosen by the user.
Also, is it justified if we ask user to run this command as superuser if in case there were permission problems while writing the file? (For ex: I didin't define TODOMAN_CONFIG
and therefore, it used XDG_CONFIG_DIRS
by default, hence I had to use sudo
while writing the configuration file)
Thanks in advance!
from todoman.
Great! Let me know if you have further questions moving forward.
from todoman.
Hi, I have thought of some decorators for the configure function:
@click.command()
@click.option("--location",
help='Stores where configuration file is present')
@click.option("--show",
help="Choose whether to show date/time both or date only")
@click.option("--path",
help="It contains where all your calendar files are presenet")
@click.option("--date_format",
help="The date format used both for displaying dates, and "
"parsing input dates. If this option is not specified "
"the ISO-8601 (%Y-%m-%d) format is used.")
@click.option("--color",
help="By default todoman disables colored output if stdout is"
" not a TTY (value auto). Set to never to disable colored"
" output entirely, or always to enable it regardless. This"
" can be overridden with the --color option.")
@click.option("--default_list",
help="The default list for adding a todo."
"If you do not specify this option, you must use "
"the --list / -l option every time you add a todo.")
@click.option("--default_due",
help="The default difference (in hours) between new todo’s "
"due date and creation date. If not specified, the "
"value is 24."
"If set to 0, the due date for new todos will not be set.")
@click.pass_context
def configure(ctx, location, path, show, date_format, color, default_list, default_due):
# Do something here
pass
Am I on the right track (Isn't it too large) ?
Thank You
from todoman.
Oh! Thanks!
Yeah! That would be much more intuitive.
from todoman.
Why was this closed? I just installed todoman and a function like that would be very useful indeed.
from todoman.
It hasn't been closed -- it's just that nobody's picked this up or had time to work on it so far.
from todoman.
Ahh sorry, thought this issue was closed with #300
from todoman.
Hi I have written a config wizard for my CLI tool which prompts the user for parameters one at a time using a click wrapper.
The CLI tool uses toml as the configuration format and the wizard relies on that, but it could be rewritten to work with ini so as not to add any dependencies to todoman.
Would the todoman maintainers have time to review such PR?
from todoman.
Yup, PRs for this are welcome.
from todoman.
@WhyNotHugo, would it be more preferable if I separated the wizard into a separate module or fully merged the code into todoman? The wizard code is already fully covered by tests, and I utilize that code in my project. So the second approach would result in less new code in todoman.
from todoman.
I think integrating it into a new module inside todoman makes sense the most.
Can you share what you already have? Maybe seeing the existing code can help get a clearer vision of what would work best.
from todoman.
Sure. Some background:
Confluence poster is a tool to post Confluence pages that are written on the local system through a text editor. Config-wise the poster may have a global config in XDG_CONFIG_HOME and config in the working directory. There could be multiple pages in one directory posted to multiple places, so the config wizard allows generating additional sections for pages. The page logic is handled by functions with 'page' in the name, so those would be irrelevant to todoman.
Confluence poster also allows storing password in the config (which is not recommended, but still is an option), so there is additional logic to handle hidden parameters.
The way I implemented the wizard is I declare an iterable of DialogParameter objects or strings which are prompted in a row, optionally with default values fed from the existing config.
This is the bag of helper functions, and this is the function that provides interactive wizard. Typer is a wrapper around click mostly focused on using parameters for command options instead of decorators, so rewriting the internals to click would be pretty fast.
Sample run:
/tmp/new_home > XDG_CONFIG_HOME="/tmp/new_home" confluence_poster create-config --home-only
Starting confluence_poster
Starting config wizard.
This wizard will guide you through creating the configuration files.
Please provide a value for author.
Comment: If the page was not updated by the username specified here, throw an error.
If this setting is omitted - username from auth section is used for checks
This parameter is optional. Press [Enter] to skip it. []: Username
Please provide a value for auth.confluence_url.
Comment: URL of confluence instance: https://localhost
Please provide a value for auth.username.
Comment: Username for authentication in Confluence: username
Please provide a value for auth.password.
Comment: Password for authentication. May be supplied through runtime option or environment
This parameter is optional. Press [Enter] to skip it.
This parameter is marked as sensitive, input is hidden:
Please provide a value for auth.is_cloud.
Comment: Whether the confluence instance is a cloud one: no
Config to be saved:
author = "Username"
[auth]
confluence_url = "https://localhost"
username = "username"
is_cloud = false
Would you like to save it as /tmp/new_home/confluence_poster/config.toml? The wizard will create all missing parent directories [Y/n]: y
Saving config as /tmp/new_home/confluence_poster/config.toml
Since a sensitive parameter was passed - saving the config file with 600 permissions.
--home-only specified, not attempting to create any more configs.
/tmp/new_home > cat confluence_poster/config.toml
author = "Username"
[auth]
confluence_url = "https://localhost"
username = "username"
is_cloud = false
from todoman.
Related Issues (20)
- Docs are filing to build on readthedocs HOT 1
- Docs are filing to build on readthedocs HOT 1
- Docs are filing to build on readthedocs HOT 1
- Navigating tasks with vim keys HOT 6
- todoman 4.3.0 not on pypi HOT 4
- 4.3.0: test_ctrl_c_clears fails HOT 3
- Click repl doesn't show up HOT 2
- categories with diacritics not handled well HOT 5
- Subcommand to get current configuration parameters HOT 1
- Can't run v4.3.2 on Slackware64-15.0 HOT 2
- Please release 4.4.0 at PyPi HOT 2
- Tasks template && time tracking HOT 1
- Flags in config file don’t apply to default commands HOT 1
- crash when creating new todo and reading description from stdin HOT 2
- Show one-line summaries when deleting multiple items
- Remember latest creation
- `todo categories` should show all categories
- Rethink flushing
- Exclude fields in list command HOT 1
- Feature request: Any plans on adding recurring tasks? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from todoman.