Giter VIP home page Giter VIP logo

Comments (4)

insanum avatar insanum commented on September 18, 2024

I like this idea... make it so. :-)

from gcalcli.

insanum avatar insanum commented on September 18, 2024

Look into using the gflags module which has the ability to transparently pass arguments down. The google-api module uses this to pass flags from main down to the oauth2 module.

from gcalcli.

tresni avatar tresni commented on September 18, 2024

@insanum Working with the gflag module isn't too bad. It's automatic output is a little ugly (and makes the help output a million miles long) but usable.

https://github.com/insanum/gcalcli/compare/gflags

Caveats

  1. Config files are now flag files, this makes old files non-compatible. Options are to either change the options file name for gcalcli v3 releases or to just let people know that if they don't fix their config files gcalcli will simply fail to run (normally with an error like "[gcalcli]" is not a valid command
  2. gflags is not config file friendly at all. I am currently injecting a --flagsfile=~/.gcalclirc flag if the file exists. This is bad as it doesn't give the user any way to choose not to include this file. That said, the fact that we don't allow people to override where we are storing oauth/cache/etc means my case for using different config files is mute (different config files for different accounts.) Might be better to allow people to specify a folder where we will look for everything. This would make loading the .gcalclirc file interesting (initial thought is we'd end up processing all flags twice if a config folder is specified, second time ignoring ~/.gcalclirc and only sourcing from the folder if it's there), but might be a better experience overall
  3. Still need to re-add most of the flag documentation, I just put placeholder help text for now.
    https://github.com/insanum/gcalcli/compare/gflags

Upsides

  1. You can use multiple and recursive --flagsfile which is cool but really not useful until the above is solved.
  2. Reduced a lot of code, basically cut the line count of the touched lines in half! (If you ignore documentation lines we still reduced about 1/3 of the touched code.)
  3. add and other commands are more natural now as you can do the --title and other flags on either side of the command. Also, added a --[no]prompt so you can only specify exactly the pieces you want and not get prompted for stuff you left out (of course if you leave out something required, it's going to fail...)

Parting Notes

Tried to keep everything reverse-compatible for now.

Due to the caveats, I didn't merge with master yet. Let me know what you think.

We should clean up some of the flags:

  • --no-cache automatically has a --nono-cache flag which is a little dumb.
  • Any flag with a "-" in it has to be accessed using FLAGS.get() since Python doesn't allow hyphens in attributes. Most places either compound/camelcase (even though case is actually ignored) or underscores.
  • Any flag starting with a number has to be access using FLAGS.get()
  • Flags like --nc, --nl, --mon, --descr, --cal are nondescript and likely to lead to confusion. e.g. Using --description would actually still allow for --descr to work while being more descriptive for new users.
  • Color flags are ordered differently then detail flags (--detail-X vs --X-color)
  • cal can probably be removed from most of the color flags (it's implied by the flag names since "owner", "reader", etc have no other meaning for us.)

That all said, it's 2AM, I'll dig more into this tomorrow (hopefully)

from gcalcli.

tresni avatar tresni commented on September 18, 2024

I started on a branch that implements most of the Parting Notes section.

gflags...gflags2

from gcalcli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.