Giter Club home page Giter Club logo

Comments (4)

kislyuk avatar kislyuk commented on July 18, 2024

Hi, thanks for your interest in argcomplete. Are you calling argcomplete.warn() outside the context of a completer callable? It is only supported in completer callables (and only when they are invoked). Can you give a complete example (including the Python portion)?

from argcomplete.

hannahbast avatar hannahbast commented on July 18, 2024

@kislyuk Thanks for the reply! I don't mean anything special. Let's just take the following simple example and let's assume I want to see the value of COMP_LINE when in autocomplete mode for debugging purposes. Let's call the file argcomplete-test.py and do eval "$(register-python-argcomplete3 ./argcomplete-test.py)" and then type ./argcomplete-test.py <TAB>. Is there any sensible way (without meddling with the bash function) to see what the print statement prints outside of a completer callable?

#!/usr/bin/env python3
# PYTHON_ARGCOMPLETE_OK

import argparse
import argcomplete
import os
import sys

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--foo', required=True, help='foo help')
    comp_line = os.getenv('COMP_LINE', '[not in AC mode]')
    print('COMP_LINE: %s' % comp_line, file=sys.stderr)
    argcomplete.autocomplete(parser)
    args = parser.parse_args()
    print(args.foo)

if __name__ == '__main__':
    main()

from argcomplete.

kislyuk avatar kislyuk commented on July 18, 2024

No - the muting of print statements is intentional. Programs that depend on argcomplete print a variety of stuff during their startup process that we don't want to be shown when pressing <TAB>.

from argcomplete.

kislyuk avatar kislyuk commented on July 18, 2024

In general, argcomplete.warn() is only supported in completers. This is because argcomplete.warn() is not instrumented to run in the caller scope until argcomplete.autocomplete() is called - and once it's called, it never returns (as described in the docs). The only reason warn() is supported in completers is that they are callbacks - they get called in the course of running autocomplete().

I'm going to close this issue now, since it doesn't seem to be describing a bug. If you feel like there's a bug or missing feature, please feel free to describe the specifics of how it would be implemented while maintaining the existing API/protocol.

from argcomplete.

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.