/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-07-04 15:04:11 UTC
  • mfrom: (1816.2.10 bzr.dev.whoami)
  • Revision ID: pqm@pqm.ubuntu.com-20060704150411-48f7a3cfd6338d24
(robey) bzr whoami foo can set your email address

Show diffs side-by-side

added added

removed removed

Lines of Context:
1788
1788
 
1789
1789
 
1790
1790
class cmd_whoami(Command):
1791
 
    """Show bzr user id."""
1792
 
    takes_options = ['email']
 
1791
    """Show or set bzr user id.
 
1792
    
 
1793
    examples:
 
1794
        bzr whoami --email
 
1795
        bzr whoami 'Frank Chu <fchu@example.com>'
 
1796
    """
 
1797
    takes_options = [ Option('email',
 
1798
                             help='display email address only'),
 
1799
                      Option('branch',
 
1800
                             help='set identity for the current branch instead of '
 
1801
                                  'globally'),
 
1802
                    ]
 
1803
    takes_args = ['name?']
 
1804
    encoding_type = 'replace'
1793
1805
    
1794
1806
    @display_command
1795
 
    def run(self, email=False):
1796
 
        try:
1797
 
            c = WorkingTree.open_containing(u'.')[0].branch.get_config()
1798
 
        except NotBranchError:
 
1807
    def run(self, email=False, branch=False, name=None):
 
1808
        if name is None:
 
1809
            # use branch if we're inside one; otherwise global config
 
1810
            try:
 
1811
                c = Branch.open_containing('.')[0].get_config()
 
1812
            except NotBranchError:
 
1813
                c = config.GlobalConfig()
 
1814
            if email:
 
1815
                self.outf.write(c.user_email() + '\n')
 
1816
            else:
 
1817
                self.outf.write(c.username() + '\n')
 
1818
            return
 
1819
 
 
1820
        # use global config unless --branch given
 
1821
        if branch:
 
1822
            c = Branch.open_containing('.')[0].get_config()
 
1823
        else:
1799
1824
            c = config.GlobalConfig()
1800
 
        if email:
1801
 
            print c.user_email()
1802
 
        else:
1803
 
            print c.username()
 
1825
        c.set_user_option('email', name)
1804
1826
 
1805
1827
 
1806
1828
class cmd_nick(Command):