Giter Club home page Giter Club logo

Comments (32)

rgbkrk avatar rgbkrk commented on August 20, 2024

I take it you're running Atom from the icon or the Applications menu?

I've been running atom from the command line, within a project and it defaults to using the project's path. However, switching this out isn't too bad. I'm a little unsure of what everyone's workflow is like.

Here's my use case/reason for project based cwd. On a project I have at work we have a script that runs our javascript and python tests in one shot. This is located at script/test and we run it from the project root.

Would a configuration option work well for you? @intothev01d is currently working on making commands configurable and we could add in a checkbox/selection for how cwd works. I'd hate to make the config too complex, but everyone has a different workflow.

Erring on the side of being helpful, if you want to go ahead and submit a PR, you only need to change the options setting in lib/script-view.coffee.

Current:

    # Default to where the user opened atom
    options =
      cwd: atom.project.getPath()
      env: process.env

To get the directory the script is in, you'll probably have to get the current editor, get the path and strip off the title

> editor = atom.workspace.getActiveEditor()
Editor {softTabs: true, displayBuffer: DisplayBuffer, handleMarkerCreated: function, declaredPropertyValues: Object, cursors: Array[1]…}
> editor.getPath()
"/Users/kyle6475/.atom/packages/script/lib/script-view.coffee"
> editor.getTitle()
"script-view.coffee"

I'm not seeing an easy way to get the directory of the current file, at least without using the tree view. Maybe there's something better in the Atom docs.

from atom-script.

EntilZha avatar EntilZha commented on August 20, 2024

I am running it from the icon.

As far as workflow, I am primarily using Atom for light, single file editing. I usually leave larger projects to IDEs. In this case, my single script happens to be generating some plots with matplotlib for a report and resides in a separate folder form my output hence my path problems.

A checkbox/switch/option would be perfect, because definitely on larger projects I would expect cwd to be the project root, but like in this case, I actually want the file to be the cwd.

I will take a look at the snippets you posted and see if I can figure something out for a PR, but I doubt I would have time for that until next week possibly. Either way, I think your suggestion of tree view is probably a good place to start since you need a little more than just the title. Does editor.getPath always return something in .atom, or will it return the path to the file the editor is editing?

from atom-script.

EntilZha avatar EntilZha commented on August 20, 2024

I can't seem to find the docs on editor.getPath(). I looked at the api and it has editor but no .getPath() in the docs. I tired looking at Model, since it inherits that, but that gives me a 404. Where might I find the docs on what the function does?

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

We'll definitely look into how to set up the config for this. I see the practicality. As far as UX is concerned though, flipping to the settings view and toggling it each time you get to a project that runs differently will be awkward. Makes me wonder if we should have a different switch for it. 😕

Does editor.getPath always return something in .atom, or will it return the path to the file the editor is editing?

editor.getPath() always returns the full path to the file if it exists (a new unsaved "untitled" file will return undefined). My example there was poor because I was editing the package directly. Here's a different example:

> editor = atom.workspace.getActiveEditor()
Editor {softTabs: true, displayBuffer: DisplayBuffer, handleMarkerCreated: function, declaredPropertyValues: Object, cursors: Array[1]…}
> editor.getPath()
"/Users/kyle6475/code/IPython/.travis.yml"

... generating some plots with matplotlib for a report

On a side note, would you be at all interested in embedded outputs like the IPython notebook within Atom, possibly in a side pane? This would be for a separate project of course, but I'm curious.

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

Weird. I only see getPath docs for Git, Project, Directory, and File. Maybe the Editor absorbs the attributes of the File?

screen shot 2014-03-05 at 12 20 08 am

I'm really not sure here, especially since I can't dig into source on GitHub (the javascript is available though). I've been having to use the dev tools in Atom quite a bit cmd-opt-i.

from atom-script.

EntilZha avatar EntilZha commented on August 20, 2024

Perhaps have it be two different but similar hotkeys and the user can bind the hotkey to what they would like (cmd+i for project, cmd+shift+i for cwd)? Wouldn't handle running it from an arbitrary root in the project though.

As far as IPython notebook that would be interesting. The workflow seems a little unclear, but you could either do: render the static version of the notebook using http://ipython.org/ipython-doc/rel-1.0.0/interactive/nbconvert.html or you could have Atom start the IPython notebook and render localhost.

What might be interesting is to see if you could connect the IPython Qtconsole with the inline images option enabled. Not sure how you would do that since Qtconsole launches another process in another window.

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

Luckily Atom lets you configure personal hotkeys all you like. We're actually going to use ⌘-shift-i for editing the command parameters before launch (see #6), but another could suffice. ⌘-opt-i? Leave shift still as the modifier for modifying the args/path?


As far as IPython notebook that would be interesting. The workflow seems a little unclear, but you could either do: render the static version of the notebook using http://ipython.org/ipython-doc/rel-1.0.0/interactive/nbconvert.html or you could have Atom start the IPython notebook and render localhost.

I have a terrible not-quite-demo that uses IPython's client libraries to connect to a running IPython notebook server. I'd like to be able to just connect to the kernels. If you want to see what I've done so far, check out http://github.com/rgbkrk/atom-ipynb. Not ready for the prime time, still hacking around and may want to make the upstream libraries more compatible with node and require. Don't get lost in the Atom boilerplate, I didn't clean that out yet.

What might be interesting is to see if you could connect the IPython Qtconsole with the inline images option enabled. Not sure how you would do that since Qtconsole launches another process in another window.

I definitely want to keep it constrained to a pane within Atom, since I can plop HTML right there.

from atom-script.

EntilZha avatar EntilZha commented on August 20, 2024

I am interested in working on the packages, but currently don't have an invite to beta version of Atom (downloaded a copy of the .app from somewhere). Is there any additional setup to start working on changing it? I am unclear where to start, but I will start reading the Atom dev docs, I am guessing there is a good guide there.

I think with the command line modifier options, you could probably have it let you pass:
-command line args
-optionally pass in directory to consider cwd or checkmark for using the file location as cwd

This might work better UIwise

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

I would start with the Creating Packages section independently, along with the tutorial on creating your first package just to know what the set up is like. After that, check out the contributing guide to make your dev environment sane for hacking on a package (apm develop script).

from atom-script.

EntilZha avatar EntilZha commented on August 20, 2024

I've been busy for the past week, but have some time to work on this. What direction are you thinking would be good to take on implementing something which allows to change the CWD for particular runs?

I could imagine one approach which is project based, saving the CWD for particular scripts in a dotfile within the project (many IDEs do this). I could also see it being within Atom's own dotfiles. The disadvantage of course is that this creates more files.

Another approach might be that I recall there being the ability to pass command line args, but don't recall how. You could display two boxes, one for the command line arg, and another for path to cwd, defaulting to the project cwd if nothing is entered.

Or maybe there is another approach I haven't thought of.

from atom-script.

smashwilson avatar smashwilson commented on August 20, 2024

I'm 👎 on adding another hotkey specifically for doing a run with a cwd specified. There are a lot of ways that you can parameterize a run and I feel like you'd quickly run out of hotkeys.

What I'd propose instead is to make ⌘-shift-i a general "parameterized run" hotkey, which shows an initial dialog that lets you customize the run in a bunch of ways (to start: cwd, path and args).

To make them sticky, maybe have a "remember" checkmark on the dialog that drops an .atom-script file with some (J|C)SON in the project root, and use any settings found there as the defaults for ⌘-i runs and ⌘-shift-i runs. I'd say that if you run with certain parameters once you're likely to be doing the same runs over and over again with that script or project.

@rgbkrk, how does that sound?

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

Yeah, I'm liking the ⌘-shift-i supermode that remembers your last run.

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

I do like the dotfiles idea as well, as people wouldn't be required to use it. It seems like it would breed additional complexities though.

from atom-script.

EntilZha avatar EntilZha commented on August 20, 2024

Agreed on the above. I think I am going to take a stab at making the parameterized run option. I haven't worked on Atom before, so it will probably be a bit of exploration of the APIs and experimentation. When I have something looking reasonable, I will make a fork and get some feedback. For now I am mostly tinkering/reading docs/looking at other package code.

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

That's great! We're all new to Atom, so don't worry.

Also checkout issue #6, as that one is also looking for config on demand.

Feel free to make a PR with the title [WIP] if you like and let us know when you want feedback or if you get stuck. I'm just plain excited to have contributors, so you're more than welcome!

from atom-script.

EntilZha avatar EntilZha commented on August 20, 2024

Sounds good.

I have been looking for a few minutes and can't seem to find what a good workflow is for using a forked copy since apm develop clones from the main repository. Suggestions? Should I just change where the repo points to (specifically point it to my fork)?

I am also looking right now for a dialog like view if you have suggestions

from atom-script.

smashwilson avatar smashwilson commented on August 20, 2024

@EntilZha: The easiest way is probably to clone it with apm develop and then just run git remote set-url origin [email protected]/myfork inside your repository.

from atom-script.

smashwilson avatar smashwilson commented on August 20, 2024

So, basically what you said 😉

from atom-script.

EntilZha avatar EntilZha commented on August 20, 2024

Went ahead and made a fork which is here:
https://github.com/EntilZha/atom-script

And my first commit, mostly tinkering with atom/script, but also adding a python test file which simply prints the cwd and command line args:
EntilZha@f8c2c03

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

Very cool. You may want to set up branches instead of committing to master so you have an easy way to merge in from upstream. This will save you some sanity later.

git checkout -b tinkering

GitHub Flow is a great guide.

from atom-script.

EntilZha avatar EntilZha commented on August 20, 2024

Spent some time on customizing the run options and pushed my changes (forgot to create a new branch before I committed the changes, but created a new branch for my future commits).

The model I am going for right now is creating some options in the view so that they persist as long as the view exists. The idea would be that these have defaults which revert to the normal run behavior. The command that I am working on adding would allow you to change the values of those options.

I setup the "backend" part, now I need to work on the UI for it.
EntilZha@46ec22c

Any ideas on how to pull up a dialog for this?

from atom-script.

EntilZha avatar EntilZha commented on August 20, 2024

Figured out using the style guide how to pull up the kind of dialog I was trying to use. Ran into a different problem, when I create a text input element, I can type just fine after bringing it up, but I can't erase input (backspace) and using arrow keys to move forward/back in the text does not work either. Ideas on what might be causing this? I am using cod elike this:

@input type: 'text'

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

Nice!

I've noticed that you can't copy from the view either. Perhaps this is the same issue.

from atom-script.

EntilZha avatar EntilZha commented on August 20, 2024

I finished a basic implementation of this here:
https://github.com/EntilZha/atom-script/tree/customized-run-option
-Changing the CWD
-Passing command arguments (ex. python --version)
-Passing script arguments

I tested with using the cwd-args.py:
-CWD to something else
-command args: --version (print the version)
-script args: test (the python script prints the script args as an array)

The UI flow likely needs to be improved, but its functional.
cmd-i: standard script run. Will run with options configured in the view, defaulting to the current default behavior
cmd-shift-i: runs cmd-i, then brings up the options dialog. To save changes, click save which changes the current view's options which will persist to runs made by either cmd-shift-i or cmd-i.

As mentioned above though, for some reason you cant backspace to delete input.

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

Awesome. I look forward to checking this out tonight.

Can you post screenshots or an animated gif?

from atom-script.

EntilZha avatar EntilZha commented on August 20, 2024

I can post screenshots, any particularly good tool for animated gifs?

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

I've been using LICEcap, it's free and fairly easy to use.

from atom-script.

EntilZha avatar EntilZha commented on August 20, 2024

Here is what it looks like when:
-Bring up the option interface, does a default options run
-Change the cwd, note the script prints a changed cwd
-change the script arguments, which appears in the printed array
-change the command argument to --version which prints the python version instead of running the script.

demo

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

That's wonderful! Nicely done. 👏 👏

Can you open a PR for this so we can review it there?

from atom-script.

EntilZha avatar EntilZha commented on August 20, 2024

Pull request opened. #74

from atom-script.

EntilZha avatar EntilZha commented on August 20, 2024

Seems like this can be closed?

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

Sure can, thanks for #74.

from atom-script.

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.