You've already forked httpie-cli
mirror of
https://github.com/httpie/cli.git
synced 2025-08-10 22:42:05 +02:00
Added anonymous sessions (--session=/file/path.json).
This commit is contained in:
@@ -16,9 +16,8 @@ DEFAULT_CONFIG_DIR = os.environ.get(
|
||||
class BaseConfigDict(dict):
|
||||
|
||||
name = None
|
||||
help = None
|
||||
helpurl = None
|
||||
about = None
|
||||
|
||||
directory = DEFAULT_CONFIG_DIR
|
||||
|
||||
def __init__(self, directory=None, *args, **kwargs):
|
||||
@@ -29,18 +28,24 @@ class BaseConfigDict(dict):
|
||||
def __getattr__(self, item):
|
||||
return self[item]
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
try:
|
||||
os.makedirs(self.directory, mode=0o700)
|
||||
except OSError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise
|
||||
def _get_path(self):
|
||||
"""Return the config file path without side-effects."""
|
||||
return os.path.join(self.directory, self.name + '.json')
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
"""Return the config file path creating basedir, if needed."""
|
||||
path = self._get_path()
|
||||
try:
|
||||
os.makedirs(os.path.dirname(path), mode=0o700)
|
||||
except OSError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise
|
||||
return path
|
||||
|
||||
@property
|
||||
def is_new(self):
|
||||
return not os.path.exists(self.path)
|
||||
return not os.path.exists(self._get_path())
|
||||
|
||||
def load(self):
|
||||
try:
|
||||
@@ -61,8 +66,8 @@ class BaseConfigDict(dict):
|
||||
self['__meta__'] = {
|
||||
'httpie': __version__
|
||||
}
|
||||
if self.help:
|
||||
self['__meta__']['help'] = self.help
|
||||
if self.helpurl:
|
||||
self['__meta__']['help'] = self.helpurl
|
||||
|
||||
if self.about:
|
||||
self['__meta__']['about'] = self.about
|
||||
@@ -82,7 +87,7 @@ class BaseConfigDict(dict):
|
||||
class Config(BaseConfigDict):
|
||||
|
||||
name = 'config'
|
||||
help = 'https://github.com/jkbr/httpie#config'
|
||||
helpurl = 'https://github.com/jkbr/httpie#config'
|
||||
about = 'HTTPie configuration file'
|
||||
|
||||
DEFAULTS = {
|
||||
|
Reference in New Issue
Block a user